Need help with structuring ProviderScope
for a production package.
#3421
-
We have a package which uses riverpod internally. This package exposes Example: class Widget1 { ... }
class Widget2 { ... }
class MyProvider {
final Widget child;
MyProvider({this.child});
// this provider is a wrapper over provider scope
}
class Example extends StatefulWidget {
const Example({super.key});
@override
State<Example> createState() => ExampleState();
}
class ExampleState extends State<Example> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyProvider(
child: Widget1(),
),
// Now when a new widget is pushed in the stack it is not able to find `ProviderScope`
);
}
} We can ask the users of this package to use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Your |
Beta Was this translation helpful? Give feedback.
Your
MyProvider
should be above MaterialApp.You probably shouldn't be overriding MaterialTheme in
MyProvider
either. But rather expose a custom Theme object that your widgets will use.