create method

T create(
  1. BuildContext context
)

Creates and returns the T instance. Called once during initialization.

Override this method or supply viewModelFactory or viewModel to the constructor. Throws UnimplementedError if none of the three is used.

Implementation

T create(BuildContext context) {
  if (viewModel != null) return viewModel!;
  if (viewModelFactory != null) return viewModelFactory!(context);
  throw UnimplementedError(
    '$runtimeType must either override create(), provide viewModelFactory, '
    'or provide viewModel.',
  );
}