Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix(mobile): settings page crashes (#7616)
Richard Shiue5a0478ad5627
diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/ai/settings_ai_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/ai/settings_ai_bloc.dartindex 6dcd52b294..44558b13b7 100644--- a/frontend/appflowy_flutter/lib/workspace/application/settings/ai/settings_ai_bloc.dart+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/ai/settings_ai_bloc.dart@@ -7,6 +7,7 @@ import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';import 'package:appflowy_result/appflowy_result.dart';import 'package:bloc/bloc.dart';+import 'package:collection/collection.dart';import 'package:freezed_annotation/freezed_annotation.dart';part 'settings_ai_bloc.freezed.dart';@@ -96,14 +97,17 @@ class SettingsAIBloc extends Bloc<SettingsAIEvent, SettingsAIState> {},didLoadAvailableModels: (List<AvailableModelPB> models) {if (state.selectedAIModel.isEmpty) {- final m = models.firstWhere((model) => model.isDefault);- _updateUserWorkspaceSetting(model: m.name);- emit(- state.copyWith(- availableModels: models,- selectedAIModel: m.name,- ),- );+ final defaultModel =+ models.firstWhereOrNull((model) => model.isDefault);+ if (defaultModel != null) {+ _updateUserWorkspaceSetting(model: defaultModel.name);+ emit(+ state.copyWith(+ availableModels: models,+ selectedAIModel: defaultModel.name,+ ),+ );+ }} else {emit(state.copyWith(