import 'package:flutter/widgets.dart'; import 'app_state.dart'; /// Makes [AppState] available to the widget tree and rebuilds dependents when /// it changes. Deliberately dependency-free — no external state package. class AppScope extends InheritedNotifier { const AppScope({super.key, required AppState state, required super.child}) : super(notifier: state); /// Subscribes the calling widget to changes. static AppState of(BuildContext context) { final scope = context.dependOnInheritedWidgetOfExactType(); assert(scope != null, 'AppScope.of() called outside an AppScope'); return scope!.notifier!; } /// Reads without subscribing — for callbacks and one-shot lookups. static AppState read(BuildContext context) { final scope = context.getInheritedWidgetOfExactType(); assert(scope != null, 'AppScope.read() called outside an AppScope'); return scope!.notifier!; } }