0

I am getting this issue while trying to run my code :

"'runZoned' is deprecated and shouldn't be used. This will be removed in v9.0.0. Use Bloc.observer/Bloc.transformer instead. Try replacing the use of the deprecated member with the replacement."

What is the correct way to replace it?

My code :

Future<void> main() {
return BlocOverrides.runZoned(
() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    name: 'tripsy-trip-dps',
    options: DefaultFirebaseOptions.currentPlatform,
  );

and

class AppBlocObserver extends BlocObserver {
@override
void onChange(BlocBase <dynamic> bloc, Change<dynamic> change) {
super.onChange(bloc, change);
log('onChange(${bloc.runtimeType}, $change)');
}

@override
void onError(BlocBase<dynamic> bloc, Object error, StackTrace stackTrace) {
log('onError(${bloc.runtimeType}, $error, $stackTrace)');
super.onError(bloc, error, stackTrace);
}
}

 Future<void> bootstrap(FutureOr<Widget> Function() builder) async {
 FlutterError.onError = (details) {
 log(details.exceptionAsString(), stackTrace: details.stack);
 };

 await runZonedGuarded(
  () async {
    await BlocOverrides.runZoned(
    () async => runApp(await builder()),
    blocObserver: AppBlocObserver(),
  );
  },
  (error, stackTrace) => log(error.toString(), stackTrace: stackTrace),
 );
 }
  • Does this answer your question? [Info: 'runZoned' is deprecated and shouldn't be used. This will be removed in v9.0.0. Use Bloc.Bloc.transformer instead](https://stackoverflow.com/questions/73685907/info-runzoned-is-deprecated-and-shouldnt-be-used-this-will-be-removed-in-v9) – tomerpacific Jan 31 '23 at 07:52
  • I tried this. But it still doesn't work – Jarosław Gawlik Jan 31 '23 at 08:53

0 Answers0