Replies: 2 comments 3 replies
-
That line is definitely a no-go You need to extract the ChangeNotifierProvider and declare it globally like you're expected to in Riverpod If you can't (such as if your ChangeNotifier is a parameter of the widget), then maybe you want to use flutter_hooks instead. You can write: HookBuilder(
builder: (context, child) {
useListenable(someChangeNotifier);
return Whatever(someChangeNotifier);
}
)
|
Beta Was this translation helpful? Give feedback.
-
By the same token, I'm using the following pattern all over my app with great success, but along the same lines, is this ok? I know the data stays forever, unless I use autoDispose main.dart
mention helper.dart
elsewhere in app, it is used as:
and in build method as:
I always wondered two things:
|
Beta Was this translation helpful? Give feedback.
-
I have some legacy
provider
code that usesChangeNotifierProvider
.Is it reasonable to replace:
With the following?:
Expanded example
Beta Was this translation helpful? Give feedback.
All reactions