1
0
mirror of https://github.com/flutter/samples.git synced 2026-03-31 08:44:26 +00:00

Samples maintenance (#435)

This commit is contained in:
Brett Morgan
2020-05-13 09:18:26 +10:00
committed by GitHub
parent 941ebebfad
commit baa1f976b2
94 changed files with 492 additions and 349 deletions

View File

@@ -24,16 +24,17 @@ class AppModel<T> extends StatefulWidget {
final T initialState;
final Widget child;
@override
_AppModelState<T> createState() => _AppModelState<T>();
static T of<T>(BuildContext context) {
final _AppModelScope<T> scope =
final scope =
context.dependOnInheritedWidgetOfExactType<_AppModelScope<T>>();
return scope.appModelState.currentState;
}
static void update<T>(BuildContext context, T newState) {
final _AppModelScope<T> scope =
final scope =
context.dependOnInheritedWidgetOfExactType<_AppModelScope<T>>();
scope.appModelState.updateState(newState);
}