我最近升级了我的Flutter 翼,开始出现以下消息:

======== Exception caught by Flutter framework =====================================================
The following assertion was thrown during runApp:
Zone mismatch.

The Flutter bindings were initialized in a different zone than is now being used. This will likely cause confusion and bugs as any zone-specific configuration will inconsistently use the configuration of the original binding initialization zone or this zone based on hard-to-predict factors such as which zone was active when a particular callback was set.
It is important to use the same zone when calling `ensureInitialized` on the binding as when calling `runApp` later.
To make this warning fatal, set BindingBase.debugZoneErrorsAreFatal to true before the bindings are initialized (i.e. as the first statement in `void main() { }`).
When the exception was thrown, this was the stack: 
#0      BindingBase.debugCheckZone.<anonymous closure> (package:flutter/src/foundation/binding.dart:497:29)
#1      BindingBase.debugCheckZone (package:flutter/src/foundation/binding.dart:502:6)
#2      runApp (package:flutter/src/widgets/binding.dart:1080:18)
#3      mainCommon.<anonymous closure> (package:cashpak_mobile/main_common.dart:20:5)
#8      mainCommon (package:cashpak_mobile/main_common.dart:19:3)
<asynchronous suspension>
(elided 4 frames from dart:async)

这将是我的班级:

Future<void> mainCommon(AppSettings appSettings) async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();

  runZonedGuarded(() {
    runApp(
      ProviderScope(
        overrides: [
          flavorConfigProvider.overrideWithValue(appSettings),
        ],
        child: DevicePreview(
          enabled: appSettings.isDev,
          builder: (context) => const MyApp(),
        ),
      ),
    );
  }, (error, stackTrace) {
    FirebaseCrashlytics.instance.recordError(error, stackTrace);
  });
}

消除应用程序中的区域不匹配错误

推荐答案

同样的事情也发生在我身上.

现在似乎不推荐使用‘runZonedGuarded’和‘runZonedGuarded’.你需要把它go 掉,然后用别的东西.在我的例子中,有一条信息提示,告诉我改用BLOCATER/BLOC.Transform.

我首先定义了Bloc.Watch=SimpleBLocWatch()(它是一个扩展的BLocWatch),然后使用了"runApp()".

这个帖子还可以帮助你:

Info: 'runZoned' is deprecated and shouldn't be used. This will be removed in v9.0.0. Use Bloc.Bloc.transformer instead

Flutter相关问答推荐

在Flutter中创建具有固定行的压缩水平列表

SupabaseFlutter 集成问题:无法更新行

在setState之后,Ffltter ListView.Builder未更新

我怎样才能go 掉这个底部导航栏上的白色背景

顶部对齐ListTile的[前导、标题、尾随]小部件

如何在flutter中使用youtube_explod_start加载下一页

Supabase Auth:重定向到 Google.com 而不是我的应用程序

在允许屏幕 Select 和点击的同时保持通用对话框显示

Flutter蓝牙 - 如何通过蓝牙从设备中获取文件?

如何与 PostgreSQL 和外部网站交互 flutter apk?

Flutterfire Configure - 未处理的异常和没有 firebase 初始化

有什么办法可以消除Flutter 中的传递依赖?

flutter 中 // 和 /// 有什么区别

为什么将 bloc 提供程序放在单独的文件/类中会引发错误?

Flutter sliver 持久化

Flutter 中出现错误空判断运算符用于空值

使用 mocktail 包进行单元测试时,类型Null不是Future类型的子类型

try 为两个下拉值添加共享首选项,但在 Flutter 上显示错误断言失败:?

如何将所有行项目平等地放在一行中?Flutter

Flutter GetX:Get.put 在 Widget 中的什么位置?