BaseView<T extends BaseViewModel<Object>> constructor

BaseView<T extends BaseViewModel<Object>>({
  1. required T viewModel,
  2. dynamic arguments,
  3. ViewConfig viewConfig = const ViewConfig(inject: true),
  4. Key? key,
})

Implementation

BaseView({required T viewModel, dynamic arguments, ViewConfig viewConfig = const ViewConfig(inject: true), super.key}) {
  if (viewConfig.inject) {
    if (viewConfig.asNewInstance) {
      this.viewModel = Locator.registerAsNew<T>(viewModel);
    } else {
      this.viewModel = Locator.register<T>(viewModel);
    }
  } else {
    this.viewModel = viewModel;
  }

  this.viewModel.arguments = arguments;
}