Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HydratedBloc errors in main.dart in both the repository and in the tutorial #4316

Open
tataDan opened this issue Jan 5, 2025 · 2 comments
Open
Assignees
Labels
bug Something isn't working documentation Documentation requested example Example application

Comments

@tataDan
Copy link

tataDan commented Jan 5, 2025

Description
The code related to HydratedBloc in lib/main.dart in both the repository and the tutorial generates errors.

Steps To Reproduce

  1. Go to lib/main.dart.
  2. See the following errors: Undefined name 'HydratedStorageDirectory' and The function 'HydratedStorageDirectory isn't defined

Expected Behavior
These errors should not exist.

Additional Context
The existing code looks like this:

...
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  Bloc.observer = const WeatherBlocObserver();
  HydratedBloc.storage = await HydratedStorage.build(
    storageDirectory: kIsWeb
        ? HydratedStorageDirectory.web
        : HydratedStorageDirectory((await getTemporaryDirectory()).path),
  );
  runApp(WeatherApp(weatherRepository: WeatherRepository()));
}

The following code appears to work:

...
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  Bloc.observer = const WeatherBlocObserver();
  HydratedBloc.storage = await HydratedStorage.build(
    storageDirectory: kIsWeb
        ? HydratedStorage.webStorageDirectory
        : await getApplicationDocumentsDirectory(),
  );
  runApp(WeatherApp(weatherRepository: WeatherRepository()));
}
@tataDan tataDan added the bug Something isn't working label Jan 5, 2025
@tataDan
Copy link
Author

tataDan commented Jan 5, 2025

It should be mentioned that the previous post refers to the flutter_weather example.

@felangel
Copy link
Owner

felangel commented Jan 5, 2025

Hi @tataDan 👋
Thanks for opening an issue and sorry for the inconvenience! I’m preparing a new release and the docs/example are updated to use the upcoming API (available on the master branch). I’ll publish a new release very shortly apologies for the confusion!

@felangel felangel self-assigned this Jan 5, 2025
@felangel felangel added example Example application documentation Documentation requested labels Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Documentation requested example Example application
Projects
None yet
Development

No branches or pull requests

2 participants