flutter_driver测试的资产加载

时间:2019-11-23 14:24:00

标签: flutter flutter-test

我遵循了Images are not visible during flutter_driver tests的指导。

通过此实现,我将使用<input class="rising" type="text" id="mad"> <input type="button" class="button" id="button1" value="Add in descending order" onclick="addToList();"> <input type="button" class="button" id="button2" value="Multiply numbers" onclick="MultiplyNumbers();"> <hr /> <p id="sadness" class="animal"></p>调用screenshots来获得以下内容。

flutter driver

在目标模拟器(IOS)上,无论是否使用 [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<…> ,屏幕都只会变黑,没有任何内容。

应用程序在CachingAssetBundle下运行良好。该应用程序有25MB的数据是通过

加载的
flutter run

1 个答案:

答案 0 :(得分:0)

此问题已解决。我的应用正在主应用loadString内部处理init_state()资产。

这对于应用程序运行时很好,但是在flutter_driver环境中不起作用。