抛出了另一个例外:处置后使用了一个应用程序。
我是新来的扑朔迷离。我在运行我的项目“糟糕的问题上错误。 ()在应用程序上,不再使用它。”
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: Size(360, 640),
builder: () => ChangeNotifierProvider<AppNotifier?>(
create: (_) => widget.appLanguage,
child: Consumer<AppNotifier>(
builder: (context, value, _) => MaterialApp(
navigatorKey: GlobalVariable.navState,
debugShowCheckedModeBanner: false,
locale: value.appLocal,
title: 'MyApp',
routes: <String, WidgetBuilder>{
'HomeScreen': (BuildContext context) => HomeScreen(),
},
theme: value.getTheme(),
supportedLocales: [
Locale('en', 'US'),
],
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
CountryLocalizations.delegate,
],
home: Builder(
builder: (context) {
return FutureBuilder(
future: DeeplinkConfig().initUniLinks(context),
builder: (_, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Container();
}
return snapshot.data as Widget;
});
},
),
),
),
));
}
I am new to Flutter. Im getting the following error messages after run my project "oops something wents wrong. please refresh the app or contact the administrator/developer" And i refresh the app after showing this error "A AppNotifier was used after being disposed. once you have called dispose() on a AppNotifier, it can no longer be used."
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: Size(360, 640),
builder: () => ChangeNotifierProvider<AppNotifier?>(
create: (_) => widget.appLanguage,
child: Consumer<AppNotifier>(
builder: (context, value, _) => MaterialApp(
navigatorKey: GlobalVariable.navState,
debugShowCheckedModeBanner: false,
locale: value.appLocal,
title: 'MyApp',
routes: <String, WidgetBuilder>{
'HomeScreen': (BuildContext context) => HomeScreen(),
},
theme: value.getTheme(),
supportedLocales: [
Locale('en', 'US'),
],
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
CountryLocalizations.delegate,
],
home: Builder(
builder: (context) {
return FutureBuilder(
future: DeeplinkConfig().initUniLinks(context),
builder: (_, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Container();
}
return snapshot.data as Widget;
});
},
),
),
),
));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此错误告诉您处置后您正在使用AppNotifier。
这是一个临时解决方案:
This error tells that you are using AppNotifier after disposal.
this is a temporary solution:
您不是在ChangeNotifierProvider的创建中创建新对象。您已经通过那里已经计算出的值。因此,当ChangeNotifierProvider的处置在内部称为时,它将被处置。
您需要做2件事。
changeNotifierProvider.value
传递widget.applanguage
。谢谢。
You are not creating new object in ChangeNotifierProvider's create. You are passing already calculated value there. Hence it will be disposed when ChangeNotifierProvider's dispose is called internally.
You need to do 2 things.
ChangeNotifierProvider.value
to passwidget.appLanguage
.Thanks.