From d83e257e41dfd54a9821b88e8cca77dfafbfcd59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=91=86=E5=91=86666?= Date: Sun, 11 Jun 2023 15:38:32 +0800 Subject: [PATCH] process #135 --- CHANGELOG.md | 3 ++- lib/src/init_dialog.dart | 21 ++++++++++++++++--- .../ephemeral/Flutter-Generated.xcconfig | 4 ++-- .../ephemeral/flutter_export_environment.sh | 4 ++-- pubspec.yaml | 2 +- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d06afa..e97d952 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -# [4.9.1] +# [4.9.x] * fix [#132](https://github.com/fluttercandies/flutter_smart_dialog/issues/132) * optimize nonAnimationTypes * toast add some param +* fix [#135](https://github.com/fluttercandies/flutter_smart_dialog/issues/135) # [4.9.0] * Breaking Change diff --git a/lib/src/init_dialog.dart b/lib/src/init_dialog.dart index b21367e..7e5c294 100644 --- a/lib/src/init_dialog.dart +++ b/lib/src/init_dialog.dart @@ -114,9 +114,16 @@ class _FlutterSmartDialogState extends State { void initState() { ViewUtils.addSafeUse(() { try { - var navigator = widget.child as Navigator; - var key = navigator.key as GlobalKey; - DialogProxy.contextNavigator = key.currentContext; + BuildContext? context; + if (widget.child is Navigator) { + context = getNavigatorContext(widget.child as Navigator); + } else if (widget.child is FocusScope) { + var focusScope = widget.child as FocusScope; + if (focusScope.child is Navigator) { + context = getNavigatorContext(focusScope.child as Navigator); + } + } + DialogProxy.contextNavigator = context; } catch (_) {} }); @@ -207,4 +214,12 @@ class _FlutterSmartDialogState extends State { ]), ); } + + BuildContext? getNavigatorContext(Navigator navigator) { + BuildContext? context; + if (navigator.key is GlobalKey) { + context = (navigator.key as GlobalKey).currentContext; + } + return context; + } } diff --git a/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig index 30cb3e9..14a6389 100644 --- a/macos/Flutter/ephemeral/Flutter-Generated.xcconfig +++ b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -3,8 +3,8 @@ FLUTTER_ROOT=/Users/xdd666/Develop/SDK/flutter_sdk FLUTTER_APPLICATION_PATH=/Users/xdd666/Develop/Github/flutter_smart_dialog COCOAPODS_PARALLEL_CODE_SIGN=true FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=4.9.1 -FLUTTER_BUILD_NUMBER=4.9.1 +FLUTTER_BUILD_NAME=4.9.2 +FLUTTER_BUILD_NUMBER=4.9.2 DART_OBFUSCATION=false TRACK_WIDGET_CREATION=true TREE_SHAKE_ICONS=false diff --git a/macos/Flutter/ephemeral/flutter_export_environment.sh b/macos/Flutter/ephemeral/flutter_export_environment.sh index e38d82a..78dc4df 100755 --- a/macos/Flutter/ephemeral/flutter_export_environment.sh +++ b/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -4,8 +4,8 @@ export "FLUTTER_ROOT=/Users/xdd666/Develop/SDK/flutter_sdk" export "FLUTTER_APPLICATION_PATH=/Users/xdd666/Develop/Github/flutter_smart_dialog" export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=4.9.1" -export "FLUTTER_BUILD_NUMBER=4.9.1" +export "FLUTTER_BUILD_NAME=4.9.2" +export "FLUTTER_BUILD_NUMBER=4.9.2" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" diff --git a/pubspec.yaml b/pubspec.yaml index 40f121d..c124cc9 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.1+1 +version: 4.9.2 homepage: https://github.com/fluttercandies/flutter_smart_dialog # flutter pub publish --server=https://pub.dartlang.org