Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/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
处理隔离内部的根束时,将显示flift WidgetsFlutterBinding.ensureInitialized()_Flutter_Dart_Dart Isolates - Fatal编程技术网

处理隔离内部的根束时,将显示flift WidgetsFlutterBinding.ensureInitialized()

处理隔离内部的根束时,将显示flift WidgetsFlutterBinding.ensureInitialized(),flutter,dart,dart-isolates,Flutter,Dart,Dart Isolates,在我的flatter应用程序中,有一项繁重的任务迫使我使用隔离,以获得流畅的用户界面,该任务包括使用rootBundle读取一些资产文件,并在其中搜索特定文本。现在,由于呈现UI的主隔离不与将为我执行繁重任务的衍生隔离共享内存,每当我尝试在衍生隔离运行的方法中使用根束时,我都会遇到以下错误: 在绑定之前已访问ServicesBinding.defaultBinaryMessenger 已初始化 当然,使用WidgetsFlutterBinding.ensureInitialized()无效。 我

在我的flatter应用程序中,有一项繁重的任务迫使我使用隔离,以获得流畅的用户界面,该任务包括使用rootBundle读取一些资产文件,并在其中搜索特定文本。现在,由于呈现UI的主隔离不与将为我执行繁重任务的衍生隔离共享内存,每当我尝试在衍生隔离运行的方法中使用根束时,我都会遇到以下错误:

在绑定之前已访问ServicesBinding.defaultBinaryMessenger 已初始化

当然,使用WidgetsFlutterBinding.ensureInitialized()无效。
我试图将根束发送到繁殖的隔离体,并在那里使用它,但没有成功。

我向颤振开发者报告了这一点:

他们回答说,这不是一个bug,可能是原样。检查颤振样本,您可以发现:

// Load the JSON string. This is done in the main isolate because spawned
// isolates do not have access to the root bundle. However, the loading
// process is asynchronous, so the UI will not block while the file is
// loaded.
完整示例文件:


我向颤振开发者报告了这一点:

他们回答说,这不是一个bug,可能是原样。检查颤振样本,您可以发现:

// Load the JSON string. This is done in the main isolate because spawned
// isolates do not have access to the root bundle. However, the loading
// process is asynchronous, so the UI will not block while the file is
// loaded.
完整示例文件:


“当然,在方法的顶部使用WidgetsFlutterBinding.ensureInitialized();不起作用”-什么方法
Isolate
的入口点(我指的是
Isolate.spawn()
的第一个参数)?@pskink将要执行的方法的引用,我接受一个SendPort参数,我甚至尝试将根束发送到生成的隔离,但仍然得到了相同的结果eror@pskink是的,我也试过了,也犯了同样的错误,这就是我说的原因“使用WidgetsFlutterBinding.ensureInitialized();因此,你似乎需要从总体上阅读你的资产isolate@pskink是的,这就是我所做的,在完成读取之后,我生成了一个隔离,在主隔离已经读取的数据中进行搜索;在方法顶部的“不起作用”-什么方法?
Isolate
的入口点(我指的是
Isolate.spawn()
的第一个参数)?@pskink将要执行的方法的引用,并且我接受一个SendPort参数,我甚至尝试将rootBundle发送到生成的隔离,但仍然得到了相同的结果eror@pskink是的,我也尝试过,但也遇到了同样的错误,这就是为什么我说“使用WidgetsFluterBinding.ensureInitialized();因此,你似乎需要从总体上阅读你的资产isolate@pskink是的,这就是我所做的,在完成读取之后,我生成了一个隔离,在主隔离已经读取的数据中进行搜索。