我想编写一个Flutter测试并模拟双击,但是我无法找到方法。
目前为止,我已经做了以下工作:
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
。
如何触发双击操作?