diff --git a/lib/src/custom/custom_dialog.dart b/lib/src/custom/custom_dialog.dart index 36ed131..649cf97 100644 --- a/lib/src/custom/custom_dialog.dart +++ b/lib/src/custom/custom_dialog.dart @@ -13,9 +13,8 @@ import 'package:flutter_smart_dialog/src/widget/attach_dialog_widget.dart'; import '../config/enum_config.dart'; import '../data/animation_param.dart'; import '../data/base_dialog.dart'; -import '../data/notify_info.dart'; -import '../smart_dialog.dart'; import '../kit/debounce_utils.dart'; +import '../smart_dialog.dart'; import '../widget/helper/smart_overlay_entry.dart'; ///main function : custom dialog diff --git a/lib/src/custom/custom_notify.dart b/lib/src/custom/custom_notify.dart index b857c72..116efd3 100644 --- a/lib/src/custom/custom_notify.dart +++ b/lib/src/custom/custom_notify.dart @@ -10,8 +10,8 @@ import '../config/enum_config.dart'; import '../data/animation_param.dart'; import '../data/base_dialog.dart'; import '../data/notify_info.dart'; -import '../smart_dialog.dart'; import '../kit/debounce_utils.dart'; +import '../smart_dialog.dart'; import '../widget/helper/smart_overlay_entry.dart'; ///main function : notify dialog diff --git a/lib/src/helper/dialog_proxy.dart b/lib/src/helper/dialog_proxy.dart index 59638fc..916e4cd 100644 --- a/lib/src/helper/dialog_proxy.dart +++ b/lib/src/helper/dialog_proxy.dart @@ -96,7 +96,6 @@ class DialogProxy { loadingWidget = CustomLoading(overlayEntry: entryLoading); } - if (initType.contains(SmartInitType.notify)) { entryNotify = SmartOverlayEntry(builder: (_) => const SizedBox.shrink()); } @@ -127,7 +126,7 @@ class DialogProxy { required BuildContext? bindWidget, required Rect? ignoreArea, }) async { - await beforeShow(); + await _beforeShow(); CustomDialog? dialog; var entry = SmartOverlayEntry( builder: (BuildContext context) => dialog!.getWidget(), @@ -180,7 +179,7 @@ class DialogProxy { required bool keepSingle, required SmartBackType backType, }) async { - await beforeShow(); + await _beforeShow(); CustomNotify? dialog; var entry = SmartOverlayEntry( builder: (BuildContext context) => dialog!.getWidget(), @@ -238,7 +237,7 @@ class DialogProxy { required bool bindPage, required BuildContext? bindWidget, }) async { - await beforeShow(); + await _beforeShow(); CustomDialog? dialog; var entry = SmartOverlayEntry( builder: (BuildContext context) => dialog!.getWidget(), @@ -293,7 +292,7 @@ class DialogProxy { required bool backDismiss, required Widget widget, }) async { - await beforeShow(); + await _beforeShow(); return loadingWidget.showLoading( alignment: alignment, clickMaskDismiss: clickMaskDismiss, @@ -332,7 +331,7 @@ class DialogProxy { required SmartToastType displayType, required Widget widget, }) async { - await beforeShow(); + await _beforeShow(); CustomToast? toast; var entry = SmartOverlayEntry( builder: (BuildContext context) => toast!.getWidget(), @@ -358,17 +357,20 @@ class DialogProxy { ); } - Completer? showCompleter; - - Future beforeShow() async { - if (showCompleter?.isCompleted == false) { - showCompleter?.complete(); - showCompleter = null; - } + Completer? _showCompleter; - showCompleter = Completer(); + Future _beforeShow() async { + _beforeShowComplete(); + _showCompleter = Completer(); await smartOverlayController.show(); - showCompleter?.complete(); + _beforeShowComplete(); + } + + void _beforeShowComplete() { + if (_showCompleter?.isCompleted == false) { + _showCompleter?.complete(); + _showCompleter = null; + } } Future? dismiss({ @@ -378,8 +380,8 @@ class DialogProxy { bool force = false, CloseType closeType = CloseType.normal, }) async { - if (showCompleter?.isCompleted == false) { - await showCompleter?.future; + if (_showCompleter?.isCompleted == false) { + await _showCompleter?.future; } if (status == SmartStatus.smart) { diff --git a/lib/src/widget/helper/smart_overlay.dart b/lib/src/widget/helper/smart_overlay.dart index fe20814..2e1ffe1 100644 --- a/lib/src/widget/helper/smart_overlay.dart +++ b/lib/src/widget/helper/smart_overlay.dart @@ -1,7 +1,7 @@ import 'dart:async'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/src/widget/helper/smart_overlay_entry.dart'; import '../../../flutter_smart_dialog.dart'; import '../../helper/dialog_proxy.dart'; @@ -66,7 +66,7 @@ class _SmartOverlayState extends State { return Overlay(initialEntries: [ if (visible) - OverlayEntry( + SmartOverlayEntry( builder: (BuildContext context) { if (widget.initType.contains(SmartInitType.custom)) { DialogProxy.contextCustom = context; diff --git a/pubspec.yaml b/pubspec.yaml index 4b4cdcd..b074b1b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: An elegant Flutter Dialog solution, Easily implement Toast, Loading and custom Dialog, Make the use of the dialog easier! -version: 4.9.7+1 +version: 4.9.7+2 homepage: https://github.com/fluttercandies/flutter_smart_dialog # flutter pub publish --server=https://pub.dartlang.org # flutter build web --release --base-href="/flutter_smart_dialog/web/"