在我的应用程序中,我使用 FlatButton.icon
创建了一个按钮( Flutter docs )。现在我试图在测试期间找到按钮。
我试过了
find.byType(MaterialButton); // -> zero widgets
find.byType(FlatButton); // -> zero widget
奇怪的是我可以找到按钮的文字
find.text('my button text');
我还可以找到按钮的图标
find.byType('Icon');
我不确定我应该搜索什么才能找到按钮。
最佳答案
好的,所以我无法找到 FlatButton 本身,但很容易找到带有 . . .
find.byIcon(Icons.yourIcon);
有关更多信息,请参阅相关文档:flutter_test find.byIcon
关于flutter - 如何在 Flutter 测试中找到 `FlatButton.icon`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62336449/