flutterdartblocpubspec

hydrated_bloc: The parameter 'storageDirectory' is required


I updated hydrated_bloc from 6.1.0 to the latest 7.0.1 and I got a warning in:

HydratedBloc.storage = await HydratedStorage.build(); The parameter 'storageDirectory' is required.

When I changed to what the new documentation suggested

HydratedBloc.storage = await HydratedStorage.build(
storageDirectory: await getTemporaryDirectory(),); The function 'getTemporaryDirectory' isn't defined.

I also tried:

HydratedBloc.storage = await HydratedStorage.build(storageDirectory: await getApplicationDocumentsDirectory(),); The function 'getApplicationDocumentsDirectory' isn't defined

Solution

  • Both getTemporaryDirectory and getApplicationDocumentsDirectory are part of the path_provider package, so, you have to import it in your main.dart file