Closed yagi2 closed 2 years ago
You should be able to use the ProviderScope
inside your story. Something like this:
Widget myStory() => ProviderScope(
overrides: [...],
child: MyView()
);
You should be able to use the overrides
property to pass the color you want to render for each story. Something like this:
Widget red() => ProviderScope(
overrides: [
colorProvider.overrideWithValue(MyColors(color: Colors.red))
],
child: MyView()
);
Widget green() => ProviderScope(
overrides: [
colorProvider.overrideWithValue(MyColors(color: Colors.green))
],
child: MyView()
);
We have sample stories which use Provider
. See provider_screen_stories.dart and provider_navigation_stories.dart. We will add sample stories for riverpod with our next release.
Thank you for sharing with me with specific samples. I'm embarrassed why I didn't realize how simple it was.
I will refer to the sample Stories as well. Thank you so much!
In my project, I am using Riverpod to dynamically change the color in the Widget using StateNotifier, so I have a component that uses ConsumerWidget.
When I try to preview a component that uses a ConsumerWidget, I get the following error
Is there any way to avoid the error and preview widget correctly?