Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.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
隔离未处理的异常:E/flift调用'WidgetsFlutterBinding.ensureInitialized()`_Flutter_Dart_Dart Isolates - Fatal编程技术网

隔离未处理的异常:E/flift调用'WidgetsFlutterBinding.ensureInitialized()`

隔离未处理的异常:E/flift调用'WidgetsFlutterBinding.ensureInitialized()`,flutter,dart,dart-isolates,Flutter,Dart,Dart Isolates,我正在使用此(照片管理器)从设备加载图像。然而,加载大量图像会导致flatter跳过帧,所以我决定将代码放在一个隔离文件中。当我在隔离区外运行以下代码时,它会正常运行: Future<List<AssetEntity>> _getImagesInDeviceAsAssetEntities({int start, int end}) async { List<AssetPathEntity> list = await PhotoManager.getAs

我正在使用此(照片管理器)从设备加载图像。然而,加载大量图像会导致flatter跳过帧,所以我决定将代码放在一个隔离文件中。当我在隔离区外运行以下代码时,它会正常运行:

Future<List<AssetEntity>> _getImagesInDeviceAsAssetEntities({int start, int end}) async {
    List<AssetPathEntity> list = await PhotoManager.getAssetPathList(
        type: RequestType.image, onlyAll: true);
    final AssetPathEntity pathEntity = list[0];
    final List<AssetEntity> assetEntityList = await pathEntity.getAssetListRange(start: start, end: end);
    return assetEntityList;
  }
注:PhotoManager.GetAssetMathlist是一种静态方法,因此其隔离是安全的

我将这一行放在runApp
WidgetsFlutterBinding.ensureInitialized()之前但它没有解决问题


有人知道发生了什么吗?

我一直面临着同样的问题,我发现这似乎是一个颤振限制,隔离物是完全隔离的,你无法访问隔离物中的插件

然而,有几个插件可以帮助实现这一点

你可以得到更多信息

[ERROR:flutter/runtime/dart_isolate.cc(865)] Unhandled exception:
E/flutter ( 2494): ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
E/flutter ( 2494): If you're running an application and need to access the binary messenger before `runApp()` has been called (for example, during plugin initialization), then you need to explicitly call the `WidgetsFlutterBinding.ensureInitialized()` first.
E/flutter ( 2494): If you're running a test, you can call the `TestWidgetsFlutterBinding.ensureInitialized()` as the first line in your test's `main()` method to initialize the binding.