diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart index 90c8abebdf101..3cc466a44a79c 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_configuration.dart @@ -1,6 +1,3 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart'; import 'package:appflowy/plugins/document/presentation/editor_page.dart'; @@ -13,6 +10,8 @@ import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor_plugins/appflowy_editor_plugins.dart'; import 'package:easy_localization/easy_localization.dart' hide TextDirection; import 'package:flowy_infra/theme_extension.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; Map getEditorBuilderMap({ diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart index cf90431c8ef24..ea94d31df3655 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_page.dart @@ -1,8 +1,5 @@ import 'dart:ui' as ui; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/plugins/document/application/document_bloc.dart'; import 'package:appflowy/plugins/document/presentation/editor_configuration.dart'; @@ -31,6 +28,8 @@ import 'package:collection/collection.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flowy_infra/theme_extension.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; final codeBlockLocalization = CodeBlockLocalizations( diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart index 4d4ed15a1f422..0675fb3bafa27 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/auto_completion_node_widget.dart @@ -188,7 +188,7 @@ class _AutoCompletionBlockComponentState Future _onGenerate() async { final loading = Loading(context); - await loading.start(); + loading.start(); await _updateEditingText(); @@ -218,7 +218,7 @@ class _AutoCompletionBlockComponentState await loading.stop(); if (mounted) { barrierDialog = BarrierDialog(context); - await barrierDialog?.show(); + barrierDialog?.show(); await _makeSurePreviousNodeIsEmptyParagraphNode(); } }, @@ -273,7 +273,7 @@ class _AutoCompletionBlockComponentState } final loading = Loading(context); - await loading.start(); + loading.start(); // clear previous response final selection = startSelection; if (selection != null) { diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/loading.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/loading.dart index 076a7877cda62..abaec7c9e9a47 100644 --- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/loading.dart +++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/openai/widgets/loading.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; class Loading { @@ -6,22 +8,24 @@ class Loading { BuildContext? loadingContext; final BuildContext context; - Future start() async => showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext context) { - loadingContext = context; - return const SimpleDialog( - elevation: 0.0, - backgroundColor: - Colors.transparent, // can change this to your preferred color - children: [ - Center( - child: CircularProgressIndicator(), - ), - ], - ); - }, + void start() => unawaited( + showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + loadingContext = context; + return const SimpleDialog( + elevation: 0.0, + backgroundColor: + Colors.transparent, // can change this to your preferred color + children: [ + Center( + child: CircularProgressIndicator(), + ), + ], + ); + }, + ), ); Future stop() async { @@ -38,14 +42,16 @@ class BarrierDialog { late BuildContext loadingContext; final BuildContext context; - Future show() async => showDialog( - context: context, - barrierDismissible: false, - barrierColor: Colors.transparent, - builder: (BuildContext context) { - loadingContext = context; - return const SizedBox.shrink(); - }, + void show() => unawaited( + showDialog( + context: context, + barrierDismissible: false, + barrierColor: Colors.transparent, + builder: (BuildContext context) { + loadingContext = context; + return const SizedBox.shrink(); + }, + ), ); Future dismiss() async => Navigator.of(loadingContext).pop();