Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何测试小部件在';它最初位于视口之外_Flutter_Testing_Dart_Widget - Fatal编程技术网

Flutter 如何测试小部件在';它最初位于视口之外

Flutter 如何测试小部件在';它最初位于视口之外,flutter,testing,dart,widget,Flutter,Testing,Dart,Widget,我有一个自定义小部件组件: class CollectAssetDataButton extends StatelessWidget { const CollectAssetDataButton({ Key key }) : super(key: key); @override Widget build(BuildContext context) { return RaisedButton( child: Text( context

我有一个自定义小部件组件:

class CollectAssetDataButton extends StatelessWidget {
  const CollectAssetDataButton({ Key key }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return RaisedButton(
        child: Text(
      context
          .translate(I18NKeys.appointmentDetails.collectAssetsData)
          .toUpperCase(),
    ),
    onPressed: () {},
  );
  }
}
我正在尝试使用以下方法进行测试:

  final collectAssetsButtonFinder = find.byKey(WidgetKeysAppointmentDetails.collectAssetsButton);
  expect(collectAssetsButtonFinder, findsOneWidget);
根据中的建议

但我仍然得到:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
  Expected: exactly one matching node in the widget tree
  Actual: _KeyFinder:<zero widgets with key [<'___appointment_details_collect_assets_button___'>]
(ignoring offstage widgets)>
   Which: means none were found but one was expected
══╡ 颤振测试框架捕获异常╞════════════════════════════════════════════════════
运行测试时引发了以下TestFailure对象:
预期:小部件树中只有一个匹配节点
实际:_KeyFinder:
这意味着除了预期的一个之外,没有找到任何对象
提前谢谢