【发布时间】:2021-07-22 11:32:58
【问题描述】:
我正在尝试编写颤振测试并模拟双标签。但我找不到办法。
这是我现在所做的:
void main() {
testWidgets('It should trigger onDoubleTap', (tester) async {
await tester.pumpWidget(MaterialApp(
home: GestureDetector(
child: const Text('button'),
onDoubleTap: () {
print('double tapped');
},
),
));
await tester.pumpAndSettle();
await tester.tap(find.text('button')); // <- Tried with tester.press too
await tester.tap(find.text('button')); // <- Tried with tester.press too
await tester.pumpAndSettle();
});
}
当我运行测试时,这是我得到的:
00:03 +1: All tests passed!
但我在控制台中没有看到任何double tapped。
如何触发双击?
【问题讨论】:
标签: flutter dart flutter-test gesturedetector single-vs-double-tap