flutter - 如何在 Flutter 小部件测试中组合两个 Finder?
问题描述
使用package:flutter_test
,我可以创建一个查找器,用一个键查找小部件:
expect(find.byKey(const ValueKey('counter')), findsOneWidget);
或通过文字:
expect(find.text('0'), findsOneWidget);
我还可以找到从这个小部件下降的小部件:
expect(
find.descendant(
of: find.byKey(const ValueKey('counter')),
matching: find.text('0'),
),
findsNothing,
);
或者祖先:
expect(
find.ancestor(
of: find.text('0'),
matching: find.byKey(const ValueKey('counter')),
),
findsNothing,
);
但是我如何结合这些查找器来验证是否有一个带有“计数器”键和“0”作为文本的小部件?例如:
Text(
'$_counter',
key: const Key('counter'),
style: Theme.of(context).textTheme.headline4,
),
解决方案
推荐阅读
- c# - 以自定义格式格式化 DataGridView 列中的日期
- c# - 如何使用 Cache-Cow 设置用户代理
- java - 如何使用时间戳获取范围内的数据 - Firebase、Android、实时数据库
- cassandra - 有没有一种方法可以在不删除 cassandra 中的模式的情况下删除键空间。如果有我该怎么做?
- webpagetest - 在webpagetest上阻止服务器推送的js
- php - 将 file_get_contents 转换为 $_FILES
- java - 将度数符号 ( ° ) 从 XML 传递到 java
- ios - 在 UIImageView 中剪辑的圆角
- vba - 将单元格引用用于自定形线
- shell - shell find 命令:混合排除目录和包含特定目录