AppScoped constructor

const AppScoped({
  1. Key? key,
  2. required AppRef appRef,
  3. required Widget child,
})

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にグローバルに定義したAppRefchildに子供のウィジェットを渡してください。

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,
});