diff --git a/CHANGELOG.md b/CHANGELOG.md index eea42a6..be0a206 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.2.0 + +- Fix deprecated API use (ButtonBar, PopInvokedCallback) + - `onPopInvoked` should be migrated to `onPopInvokedWithResult` + - https://docs.flutter.dev/release/breaking-changes/popscope-with-result + ## 2.1.0 - Add `spellCheckConfiguration` to `DialogTextField` diff --git a/example/lib/pages/alert_page.dart b/example/lib/pages/alert_page.dart index c867df0..890b436 100644 --- a/example/lib/pages/alert_page.dart +++ b/example/lib/pages/alert_page.dart @@ -41,6 +41,9 @@ class AlertPage extends StatelessWidget { title: 'Title', message: 'This is message.', canPop: false, + onPopInvokedWithResult: (didPop, result) { + logger.info('didPop: $didPop, result: $result'); + }, ); assert(result == OkCancelResult.ok); logger.info(result); diff --git a/example/pubspec.lock b/example/pubspec.lock index 8cf3f63..7232d20 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -20,7 +20,7 @@ packages: path: ".." relative: true source: path - version: "2.1.0" + version: "2.1.1" analyzer: dependency: transitive description: diff --git a/lib/src/alert_dialog/show_alert_dialog.dart b/lib/src/alert_dialog/show_alert_dialog.dart index c6f3695..01511bc 100644 --- a/lib/src/alert_dialog/show_alert_dialog.dart +++ b/lib/src/alert_dialog/show_alert_dialog.dart @@ -29,7 +29,7 @@ Future showAlertDialog({ VerticalDirection actionsOverflowDirection = VerticalDirection.up, bool fullyCapitalizedForMaterial = true, bool canPop = true, - PopInvokedCallback? onPopInvoked, + PopInvokedWithResultCallback? onPopInvokedWithResult, AdaptiveDialogBuilder? builder, Widget? macOSApplicationIcon, RouteSettings? routeSettings, @@ -53,7 +53,7 @@ Future showAlertDialog({ style: style, useRootNavigator: useRootNavigator, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, builder: builder, routeSettings: routeSettings, ); @@ -74,7 +74,7 @@ Future showAlertDialog({ builder: (context) { final dialog = PopScope( canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, child: CupertinoAlertDialog( title: titleText, content: messageText, @@ -111,7 +111,7 @@ Future showAlertDialog({ final Widget dialog = MacThemeWrapper( child: PopScope( canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, child: MacosAlertDialog( title: titleText ?? const SizedBox.shrink(), message: messageText ?? const SizedBox.shrink(), @@ -140,7 +140,7 @@ Future showAlertDialog({ builder: (context) { final dialog = PopScope( canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, child: AlertDialog( title: titleText, content: messageText, diff --git a/lib/src/alert_dialog/show_confirmation_dialog.dart b/lib/src/alert_dialog/show_confirmation_dialog.dart index aad746a..0efe65b 100644 --- a/lib/src/alert_dialog/show_confirmation_dialog.dart +++ b/lib/src/alert_dialog/show_confirmation_dialog.dart @@ -33,7 +33,7 @@ Future showConfirmationDialog({ bool shrinkWrap = true, bool fullyCapitalizedForMaterial = true, bool canPop = true, - PopInvokedCallback? onPopInvoked, + PopInvokedWithResultCallback? onPopInvokedWithResult, AdaptiveDialogBuilder? builder, RouteSettings? routeSettings, bool toggleable = true, @@ -66,7 +66,7 @@ Future showConfirmationDialog({ shrinkWrap: shrinkWrap, fullyCapitalized: fullyCapitalizedForMaterial, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, toggleable: toggleable, ); return builder == null ? dialog : builder(context, dialog); @@ -81,7 +81,7 @@ Future showConfirmationDialog({ style: style, useRootNavigator: useRootNavigator, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, builder: builder, routeSettings: routeSettings, ); @@ -101,7 +101,7 @@ class _ConfirmationMaterialDialog extends StatefulWidget { required this.shrinkWrap, required this.fullyCapitalized, required this.canPop, - required this.onPopInvoked, + required this.onPopInvokedWithResult, required this.toggleable, }); @@ -116,7 +116,7 @@ class _ConfirmationMaterialDialog extends StatefulWidget { final bool shrinkWrap; final bool fullyCapitalized; final bool canPop; - final PopInvokedCallback? onPopInvoked; + final PopInvokedWithResultCallback? onPopInvokedWithResult; final bool toggleable; @override @@ -144,6 +144,7 @@ class _ConfirmationMaterialDialogState final message = widget.message; return PopScope( canPop: widget.canPop, + onPopInvokedWithResult: widget.onPopInvokedWithResult, child: Dialog( child: Column( mainAxisSize: MainAxisSize.min, diff --git a/lib/src/alert_dialog/show_ok_alert_dialog.dart b/lib/src/alert_dialog/show_ok_alert_dialog.dart index 60f8d77..4a40e35 100644 --- a/lib/src/alert_dialog/show_ok_alert_dialog.dart +++ b/lib/src/alert_dialog/show_ok_alert_dialog.dart @@ -22,7 +22,7 @@ Future showOkAlertDialog({ VerticalDirection actionsOverflowDirection = VerticalDirection.up, bool fullyCapitalizedForMaterial = true, bool canPop = true, - PopInvokedCallback? onPopInvoked, + PopInvokedWithResultCallback? onPopInvokedWithResult, AdaptiveDialogBuilder? builder, RouteSettings? routeSettings, }) async { @@ -41,7 +41,7 @@ Future showOkAlertDialog({ actionsOverflowDirection: actionsOverflowDirection, fullyCapitalizedForMaterial: fullyCapitalizedForMaterial, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, builder: builder, actions: [ AlertDialogAction( diff --git a/lib/src/alert_dialog/show_ok_cancel_alert_dialog.dart b/lib/src/alert_dialog/show_ok_cancel_alert_dialog.dart index e55b0a9..7678ec7 100644 --- a/lib/src/alert_dialog/show_ok_cancel_alert_dialog.dart +++ b/lib/src/alert_dialog/show_ok_cancel_alert_dialog.dart @@ -31,7 +31,7 @@ Future showOkCancelAlertDialog({ VerticalDirection actionsOverflowDirection = VerticalDirection.up, bool fullyCapitalizedForMaterial = true, bool canPop = true, - PopInvokedCallback? onPopInvoked, + PopInvokedWithResultCallback? onPopInvokedWithResult, AdaptiveDialogBuilder? builder, RouteSettings? routeSettings, }) async { @@ -55,7 +55,7 @@ Future showOkCancelAlertDialog({ actionsOverflowDirection: actionsOverflowDirection, fullyCapitalizedForMaterial: fullyCapitalizedForMaterial, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, builder: builder, actions: [ AlertDialogAction( diff --git a/lib/src/modal_action_sheet/cupertino_modal_action_sheet.dart b/lib/src/modal_action_sheet/cupertino_modal_action_sheet.dart index 21715ee..21cc180 100644 --- a/lib/src/modal_action_sheet/cupertino_modal_action_sheet.dart +++ b/lib/src/modal_action_sheet/cupertino_modal_action_sheet.dart @@ -14,7 +14,7 @@ class CupertinoModalActionSheet extends StatelessWidget { this.message, this.cancelLabel, required this.canPop, - required this.onPopInvoked, + required this.onPopInvokedWithResult, }); final ActionCallback onPressed; @@ -23,7 +23,7 @@ class CupertinoModalActionSheet extends StatelessWidget { final String? message; final String? cancelLabel; final bool canPop; - final PopInvokedCallback? onPopInvoked; + final PopInvokedWithResultCallback? onPopInvokedWithResult; @override Widget build(BuildContext context) { @@ -31,7 +31,7 @@ class CupertinoModalActionSheet extends StatelessWidget { final message = this.message; return PopScope( canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, child: MediaQuery.withClampedTextScaling( minScaleFactor: 1, child: CupertinoActionSheet( diff --git a/lib/src/modal_action_sheet/material_modal_action_sheet.dart b/lib/src/modal_action_sheet/material_modal_action_sheet.dart index 2d6da56..2c73280 100644 --- a/lib/src/modal_action_sheet/material_modal_action_sheet.dart +++ b/lib/src/modal_action_sheet/material_modal_action_sheet.dart @@ -12,7 +12,7 @@ class MaterialModalActionSheet extends StatelessWidget { this.message, this.materialConfiguration, required this.canPop, - required this.onPopInvoked, + required this.onPopInvokedWithResult, }); final ActionCallback onPressed; @@ -21,7 +21,7 @@ class MaterialModalActionSheet extends StatelessWidget { final String? message; final MaterialModalActionSheetConfiguration? materialConfiguration; final bool canPop; - final PopInvokedCallback? onPopInvoked; + final PopInvokedWithResultCallback? onPopInvokedWithResult; @override Widget build(BuildContext context) { @@ -90,7 +90,7 @@ class MaterialModalActionSheet extends StatelessWidget { ); return PopScope( canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, child: body, ); } diff --git a/lib/src/modal_action_sheet/modal_action_sheet.dart b/lib/src/modal_action_sheet/modal_action_sheet.dart index f3b77fe..cbc3780 100644 --- a/lib/src/modal_action_sheet/modal_action_sheet.dart +++ b/lib/src/modal_action_sheet/modal_action_sheet.dart @@ -24,7 +24,7 @@ Future showModalActionSheet({ bool useRootNavigator = true, MaterialModalActionSheetConfiguration? materialConfiguration, bool canPop = true, - PopInvokedCallback? onPopInvoked, + PopInvokedWithResultCallback? onPopInvokedWithResult, AdaptiveDialogBuilder? builder, RouteSettings? routeSettings, }) { @@ -50,7 +50,7 @@ Future showModalActionSheet({ actions: actions, materialConfiguration: materialConfiguration, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, ); return builder == null ? sheet : builder(context, sheet); }, @@ -67,7 +67,7 @@ Future showModalActionSheet({ actions: actions, cancelLabel: cancelLabel, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, ); return builder == null ? sheet : builder(context, sheet); }, diff --git a/lib/src/text_input_dialog/ios_text_input_dialog.dart b/lib/src/text_input_dialog/ios_text_input_dialog.dart index ce59b80..5e11d86 100644 --- a/lib/src/text_input_dialog/ios_text_input_dialog.dart +++ b/lib/src/text_input_dialog/ios_text_input_dialog.dart @@ -16,7 +16,7 @@ class IOSTextInputDialog extends StatefulWidget { this.style = AdaptiveStyle.adaptive, this.useRootNavigator = true, required this.canPop, - required this.onPopInvoked, + required this.onPopInvokedWithResult, this.autoSubmit = false, }); @override @@ -31,7 +31,7 @@ class IOSTextInputDialog extends StatefulWidget { final AdaptiveStyle style; final bool useRootNavigator; final bool canPop; - final PopInvokedCallback? onPopInvoked; + final PopInvokedWithResultCallback?>? onPopInvokedWithResult; final bool autoSubmit; } @@ -114,6 +114,7 @@ class _IOSTextInputDialogState extends State { final validationMessage = _validationMessage; return PopScope( canPop: widget.canPop, + onPopInvokedWithResult: widget.onPopInvokedWithResult, child: CupertinoAlertDialog( title: title == null ? null : Text(title), content: Column( diff --git a/lib/src/text_input_dialog/macos_text_input_dialog.dart b/lib/src/text_input_dialog/macos_text_input_dialog.dart index be1f245..05dc67d 100644 --- a/lib/src/text_input_dialog/macos_text_input_dialog.dart +++ b/lib/src/text_input_dialog/macos_text_input_dialog.dart @@ -19,7 +19,7 @@ class MacOSTextInputDialog extends StatefulWidget { this.style = AdaptiveStyle.adaptive, this.useRootNavigator = true, required this.canPop, - required this.onPopInvoked, + required this.onPopInvokedWithResult, this.autoSubmit = false, }); @override @@ -34,7 +34,7 @@ class MacOSTextInputDialog extends StatefulWidget { final AdaptiveStyle style; final bool useRootNavigator; final bool canPop; - final PopInvokedCallback? onPopInvoked; + final PopInvokedWithResultCallback?>? onPopInvokedWithResult; final bool autoSubmit; } diff --git a/lib/src/text_input_dialog/material_text_input_dialog.dart b/lib/src/text_input_dialog/material_text_input_dialog.dart index fadefba..107fc82 100644 --- a/lib/src/text_input_dialog/material_text_input_dialog.dart +++ b/lib/src/text_input_dialog/material_text_input_dialog.dart @@ -17,7 +17,7 @@ class MaterialTextInputDialog extends StatefulWidget { this.useRootNavigator = true, this.fullyCapitalized = true, required this.canPop, - required this.onPopInvoked, + required this.onPopInvokedWithResult, this.autoSubmit = false, }); @override @@ -35,7 +35,7 @@ class MaterialTextInputDialog extends StatefulWidget { final bool useRootNavigator; final bool fullyCapitalized; final bool canPop; - final PopInvokedCallback? onPopInvoked; + final PopInvokedWithResultCallback?>? onPopInvokedWithResult; final bool autoSubmit; } @@ -95,6 +95,7 @@ class _MaterialTextInputDialogState extends State { ); return PopScope( canPop: widget.canPop, + onPopInvokedWithResult: widget.onPopInvokedWithResult, child: Form( key: _formKey, child: AlertDialog( diff --git a/lib/src/text_input_dialog/show_text_answer_dialog.dart b/lib/src/text_input_dialog/show_text_answer_dialog.dart index b130e06..d1731cc 100644 --- a/lib/src/text_input_dialog/show_text_answer_dialog.dart +++ b/lib/src/text_input_dialog/show_text_answer_dialog.dart @@ -22,7 +22,7 @@ Future showTextAnswerDialog({ VerticalDirection actionsOverflowDirection = VerticalDirection.up, bool fullyCapitalizedForMaterial = true, bool canPop = true, - PopInvokedCallback? onPopInvoked, + PopInvokedWithResultCallback?>? onPopInvokedWithResult, bool autoSubmit = false, bool isCaseSensitive = true, AdaptiveDialogBuilder? builder, @@ -42,7 +42,7 @@ Future showTextAnswerDialog({ actionsOverflowDirection: actionsOverflowDirection, fullyCapitalizedForMaterial: fullyCapitalizedForMaterial, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, autoSubmit: autoSubmit, builder: builder, ); @@ -66,8 +66,6 @@ Future showTextAnswerDialog({ barrierDismissible: barrierDismissible, useRootNavigator: useRootNavigator, fullyCapitalizedForMaterial: fullyCapitalizedForMaterial, - canPop: canPop, - onPopInvoked: onPopInvoked, builder: builder, ); return result == OkCancelResult.ok @@ -90,7 +88,7 @@ Future showTextAnswerDialog({ actionsOverflowDirection: actionsOverflowDirection, fullyCapitalizedForMaterial: fullyCapitalizedForMaterial, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, autoSubmit: autoSubmit, builder: builder, ) diff --git a/lib/src/text_input_dialog/show_text_input_dialog.dart b/lib/src/text_input_dialog/show_text_input_dialog.dart index 85b1d52..072c0cb 100644 --- a/lib/src/text_input_dialog/show_text_input_dialog.dart +++ b/lib/src/text_input_dialog/show_text_input_dialog.dart @@ -25,7 +25,7 @@ Future?> showTextInputDialog({ VerticalDirection actionsOverflowDirection = VerticalDirection.up, bool fullyCapitalizedForMaterial = true, bool canPop = true, - PopInvokedCallback? onPopInvoked, + PopInvokedWithResultCallback?>? onPopInvokedWithResult, bool autoSubmit = false, AdaptiveDialogBuilder? builder, RouteSettings? routeSettings, @@ -52,7 +52,7 @@ Future?> showTextInputDialog({ style: adaptiveStyle, useRootNavigator: useRootNavigator, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, autoSubmit: autoSubmit, ); return builder == null ? dialog : builder(context, dialog); @@ -75,7 +75,7 @@ Future?> showTextInputDialog({ style: adaptiveStyle, useRootNavigator: useRootNavigator, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, autoSubmit: autoSubmit, ), ); @@ -103,7 +103,7 @@ Future?> showTextInputDialog({ useRootNavigator: useRootNavigator, fullyCapitalized: fullyCapitalizedForMaterial, canPop: canPop, - onPopInvoked: onPopInvoked, + onPopInvokedWithResult: onPopInvokedWithResult, autoSubmit: autoSubmit, ); return builder == null ? dialog : builder(context, dialog); diff --git a/pubspec.yaml b/pubspec.yaml index 775e833..0de8f15 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: adaptive_dialog description: Show alert dialog or modal action sheet adaptively according to platform. -version: 2.1.0 +version: 2.2.0 repository: https://github.com/mono0926/adaptive_dialog funding: - https://github.com/sponsors/mono0926