loadDynamicModels method

Future<void> loadDynamicModels(
  1. List<Model> modelsFromCode
)

Implementation

Future<void> loadDynamicModels(List<Model> modelsFromCode) async {
  emit(state.copyWith(isLoading: true, isError: false));
  try {
    final List<Model> models = await modelProvider.fetchModels();
    await _sortAndSplitModels(
      modelsFromCode: modelsFromCode,
      dynamicModels: models,
    );
  } catch (error) {
    emit(state.copyWith(
      isError: true,
      isLoading: false,
    ));
    throw error.toHumanException('Dynamic models loading failed!');
  }
  emit(state.copyWith(isLoading: false));
}