【发布时间】:2020-03-19 08:58:34
【问题描述】:
我遵循了Images are not visible during flutter_driver tests的指导。
通过这个实现,我使用screenshots 得到以下调用flutter driver。
[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: inheritFromWidgetOfExactType(DefaultAssetBundle) or inheritFromElement() was called before MyAppState.initState() completed.
When an inherited widget changes, for example if the value of Theme.of() changes, its dependent widgets are rebuilt. If the dependent widget's reference to the inherited widget is in a constructor or an initState() method, then the rebuilt dependent widget will not reflect the changes in the inherited widget.
Typically references to inherited widgets should occur in widget build() methods. Alternatively, initialization based on inherited widgets can be placed in the didChangeDependencies method, which is called after initState and whenever the dependencies change thereafter.
#0 StatefulElement.inheritFromElement.<anonymous closure> (package:flutter/src/widgets/framework.dart:4164:9)
#1 StatefulElement.inheritFromElement (package:flutter/src/widgets/framework.dart:4207:6)
#2 Element.inheritFromWidgetOfExactTyp<…>
在目标模拟器 (IOS) 上,无论是否使用CachingAssetBundle,屏幕都会变黑,没有内容。
应用程序在flutter run 下运行良好。该应用程序有 25MB 的数据通过
String data = await DefaultAssetBundle.of(context).loadString(
"assets/data/repeats.json",
cache: false);
【问题讨论】:
标签: flutter flutter-test