getState<U extends ViewState<T>> method

U getState<U extends ViewState<T>>()

Gets the state associated with this ViewWidget class

Implementation

U getState<U extends ViewState<T>>() {
  assert(
    _stateInstance.value is U,
    'getState failed because the constructed State class is of type '
    '${_stateInstance.value.runtimeType} which does not match the generic type $U. Possible causes:\n'
    ' - You did not override the function `createState`. See the docs for `createState` for more information.'
    ' - The generic was omitted. E.g., you used `getState()` instead of `getState<MyWidgetState>().`',
  );
  return _stateInstance.value as U;
}