代码拉取完成,页面将自动刷新
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
class _SingleTouchRecognizer extends OneSequenceGestureRecognizer {
int _p = 0;
@override
void addAllowedPointer(PointerDownEvent event) {
//first register the current pointer so that related events will be handled by this recognizer
startTrackingPointer(event.pointer);
//ignore event if another event is already in progress
if (_p == 0) {
resolve(GestureDisposition.rejected);
_p = event.pointer;
} else {
resolve(GestureDisposition.accepted);
}
}
@override
// TODO: implement debugDescription
String get debugDescription => throw UnimplementedError();
@override
void didStopTrackingLastPointer(int pointer) {
// TODO: implement didStopTrackingLastPointer
}
@override
void handleEvent(PointerEvent event) {
if (!event.down && event.pointer == _p) {
_p = 0;
}
}
}
class SingleTouchRecognizerWidget extends StatelessWidget {
final Widget child;
SingleTouchRecognizerWidget({this.child});
@override
Widget build(BuildContext context) {
return RawGestureDetector(
gestures: <Type, GestureRecognizerFactory>{
_SingleTouchRecognizer: GestureRecognizerFactoryWithHandlers<_SingleTouchRecognizer>(
() => _SingleTouchRecognizer(),
(_SingleTouchRecognizer instance) {},
),
},
child: child,
);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。