Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined name 'HydratedBlocOverrides'

I am a Beginner in flutter and i was learning hydratedBloc, i imported all the needed dependencies as in the tutorial i was following and i run into a problem where my HydratedBlocOverrrides.runZoned is marked as an error [This is the screenshot containing the errorthis is the Bloc_Imports files containg the exported hydratedBloc](https://i.sstatic.net/fVTcR.png) Why do i have this error?

I tried using HydratedBloc to locally store data,i imported hydratedBloc but this syntax was marked and error "Undefined Name" refering to this HydratedBlocOverrrides.runZoned

image

like image 538
Tinagyei Emmanuel Avatar asked Oct 17 '25 05:10

Tinagyei Emmanuel


1 Answers

According to hydrated_bloc's Changelog in version 9.0.0. It has removed HydratedBlocOverrides

BREAKING: feat!: reintroduce HydratedBloc.storage and remove HydratedBlocOverrides (#3479) upgrade to bloc: ^8.1.0

Therefore change your code from:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final storage = await HydratedStorage.build(
      storageDirectory: await getApplicationDocumentsDirectory());
  HydratedBlocOverrides.runZoned(
    () => runApp(const MyApp()),
    storage: storage,
  );
}

to

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  HydratedBloc.storage = await HydratedStorage.build(
    storageDirectory: await getTemporaryDirectory(),
  );
  runApp(const MyApp());
}
like image 122
krishnaacharyaa Avatar answered Oct 18 '25 19:10

krishnaacharyaa