AppScoped constructor
Place it close to the route (e.g., on top of MaterialApp) to use state management in the app.
Pass the globally defined AppRef in appRef and the child widget in child.
アプリ内で状態管理を利用するためにルートに近い場所(MaterialAppの上など)に置いてください。
appRefにグローバルに定義したAppRef、childに子供のウィジェットを渡してください。
final appRef = AppRef();
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp();
@override
Widget build(BuildContext context){
return AppScoped(
appRef: appRef,
child: MaterialApp(
~~~~~
),
);
}
}
Implementation
const AppScoped({
super.key,
required this.appRef,
required this.child,
});