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

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());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With