mirror of https://github.com/flutter/samples.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
672 B
28 lines
672 B
import 'package:flutter/widgets.dart';
|
|
|
|
import 'app_state.dart';
|
|
|
|
class AppStateManager extends InheritedWidget {
|
|
const AppStateManager({
|
|
super.key,
|
|
required super.child,
|
|
required AppState state,
|
|
}) : _appState = state;
|
|
|
|
static AppStateManager of(BuildContext context) {
|
|
final AppStateManager? result =
|
|
context.dependOnInheritedWidgetOfExactType<AppStateManager>();
|
|
assert(result != null, 'No AppStateManager found in context');
|
|
return result!;
|
|
}
|
|
|
|
final AppState _appState;
|
|
|
|
AppState get appState => _appState;
|
|
|
|
@override
|
|
bool updateShouldNotify(AppStateManager oldWidget) {
|
|
return appState != oldWidget.appState;
|
|
}
|
|
}
|