1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-19 21:46:29 +00:00

Analysis options, fixes and format (#106)

This commit is contained in:
Brett Morgan
2019-07-04 15:42:59 +10:00
committed by GitHub
parent 90ecd8df25
commit 01478f5e88
9 changed files with 72 additions and 55 deletions

View File

@@ -26,19 +26,19 @@ class AppModel<T> extends StatefulWidget {
_AppModelState<T> createState() => _AppModelState<T>();
static _typeOf<T>() => T;
static Type _typeOf<T>() => T;
static T of<T>(BuildContext context) {
final Type appModelScopeType = _typeOf<_AppModelScope<T>>();
final _AppModelScope<T> scope =
context.inheritFromWidgetOfExactType(appModelScopeType);
final _AppModelScope<T> scope = context
.inheritFromWidgetOfExactType(appModelScopeType) as _AppModelScope<T>;
return scope.appModelState.currentState;
}
static void update<T>(BuildContext context, T newState) {
final Type appModelScopeType = _typeOf<_AppModelScope<T>>();
final _AppModelScope<T> scope =
context.inheritFromWidgetOfExactType(appModelScopeType);
final _AppModelScope<T> scope = context
.inheritFromWidgetOfExactType(appModelScopeType) as _AppModelScope<T>;
scope.appModelState.updateState(newState);
}
}