【发布时间】:2018-10-06 16:18:09
【问题描述】:
我一直在尝试测试一个元素,当按下 IconButton 时,Text 对象会更改为 TextFormField。当我尝试对此进行测试时,出现以下错误:
A Timer is still pending even after the widget tree was disposed.
'package:flutter_test/src/binding.dart': Failed assertion: line 672 pos 7:
'_fakeAsync.nonPeriodicTimerCount == 0'
尽管小部件没有使用我知道的任何计时器?
示例代码:
await tester.tap(find.byType(IconButton));
await tester.pump();
expect(find.byType(TextFormField), findsOneWidget);
await tester.pump();
await tester.enterText(find.byType(EditableText), "0.2");
我真的不确定是什么导致了问题,但是如果我删除最后两行,它运行良好(尽管我没有实际测试我的输入)。
【问题讨论】:
标签: testing dart flutter flutter-test