【问题标题】:How to find 'selected' ListTile with Flutter widget tester?如何使用 Flutter 小部件测试器找到“选定的”ListTile?
【发布时间】:2020-01-16 03:29:32
【问题描述】:

我正在为 Flutter 中带有 ListTile 元素的简单 ListView 编写小部件测试,并想测试元素是否已突出显示。

如何找到符合“选定”条件的给定类型的小部件?

Finder finder = find.byType(ListTile); // how to filter out only selected

【问题讨论】:

    标签: flutter flutter-test


    【解决方案1】:

    你可以使用byWidgetPredicate:

    Finder finder = find.byWidgetPredicate((w) => w is ListTile && w.selected);
    

    【讨论】:

      猜你喜欢
      • 2022-12-12
      • 2021-02-04
      • 2019-02-25
      • 2021-05-09
      • 2019-10-31
      • 2021-05-14
      • 2021-10-30
      • 2019-05-23
      • 1970-01-01
      相关资源
      最近更新 更多