Skip to content

Commit

Permalink
Fix deprecated API use (ButtonBar, PopInvokedCallback)
Browse files Browse the repository at this point in the history
  • Loading branch information
mono0926 committed Aug 27, 2024
1 parent cd64019 commit 34f65a1
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 40 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
3 changes: 3 additions & 0 deletions example/lib/pages/alert_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.0"
version: "2.1.1"
analyzer:
dependency: transitive
description:
Expand Down
10 changes: 5 additions & 5 deletions lib/src/alert_dialog/show_alert_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Future<T?> showAlertDialog<T>({
VerticalDirection actionsOverflowDirection = VerticalDirection.up,
bool fullyCapitalizedForMaterial = true,
bool canPop = true,
PopInvokedCallback? onPopInvoked,
PopInvokedWithResultCallback<T>? onPopInvokedWithResult,
AdaptiveDialogBuilder? builder,
Widget? macOSApplicationIcon,
RouteSettings? routeSettings,
Expand All @@ -53,7 +53,7 @@ Future<T?> showAlertDialog<T>({
style: style,
useRootNavigator: useRootNavigator,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
builder: builder,
routeSettings: routeSettings,
);
Expand All @@ -74,7 +74,7 @@ Future<T?> showAlertDialog<T>({
builder: (context) {
final dialog = PopScope(
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
child: CupertinoAlertDialog(
title: titleText,
content: messageText,
Expand Down Expand Up @@ -111,7 +111,7 @@ Future<T?> showAlertDialog<T>({
final Widget dialog = MacThemeWrapper(
child: PopScope(
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
child: MacosAlertDialog(
title: titleText ?? const SizedBox.shrink(),
message: messageText ?? const SizedBox.shrink(),
Expand Down Expand Up @@ -140,7 +140,7 @@ Future<T?> showAlertDialog<T>({
builder: (context) {
final dialog = PopScope(
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
child: AlertDialog(
title: titleText,
content: messageText,
Expand Down
11 changes: 6 additions & 5 deletions lib/src/alert_dialog/show_confirmation_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Future<T?> showConfirmationDialog<T>({
bool shrinkWrap = true,
bool fullyCapitalizedForMaterial = true,
bool canPop = true,
PopInvokedCallback? onPopInvoked,
PopInvokedWithResultCallback<T>? onPopInvokedWithResult,
AdaptiveDialogBuilder? builder,
RouteSettings? routeSettings,
bool toggleable = true,
Expand Down Expand Up @@ -66,7 +66,7 @@ Future<T?> showConfirmationDialog<T>({
shrinkWrap: shrinkWrap,
fullyCapitalized: fullyCapitalizedForMaterial,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
toggleable: toggleable,
);
return builder == null ? dialog : builder(context, dialog);
Expand All @@ -81,7 +81,7 @@ Future<T?> showConfirmationDialog<T>({
style: style,
useRootNavigator: useRootNavigator,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
builder: builder,
routeSettings: routeSettings,
);
Expand All @@ -101,7 +101,7 @@ class _ConfirmationMaterialDialog<T> extends StatefulWidget {
required this.shrinkWrap,
required this.fullyCapitalized,
required this.canPop,
required this.onPopInvoked,
required this.onPopInvokedWithResult,
required this.toggleable,
});

Expand All @@ -116,7 +116,7 @@ class _ConfirmationMaterialDialog<T> extends StatefulWidget {
final bool shrinkWrap;
final bool fullyCapitalized;
final bool canPop;
final PopInvokedCallback? onPopInvoked;
final PopInvokedWithResultCallback<T>? onPopInvokedWithResult;
final bool toggleable;

@override
Expand Down Expand Up @@ -144,6 +144,7 @@ class _ConfirmationMaterialDialogState<T>
final message = widget.message;
return PopScope(
canPop: widget.canPop,
onPopInvokedWithResult: widget.onPopInvokedWithResult,
child: Dialog(
child: Column(
mainAxisSize: MainAxisSize.min,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/alert_dialog/show_ok_alert_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Future<OkCancelResult> showOkAlertDialog({
VerticalDirection actionsOverflowDirection = VerticalDirection.up,
bool fullyCapitalizedForMaterial = true,
bool canPop = true,
PopInvokedCallback? onPopInvoked,
PopInvokedWithResultCallback<OkCancelResult>? onPopInvokedWithResult,
AdaptiveDialogBuilder? builder,
RouteSettings? routeSettings,
}) async {
Expand All @@ -41,7 +41,7 @@ Future<OkCancelResult> showOkAlertDialog({
actionsOverflowDirection: actionsOverflowDirection,
fullyCapitalizedForMaterial: fullyCapitalizedForMaterial,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
builder: builder,
actions: [
AlertDialogAction(
Expand Down
4 changes: 2 additions & 2 deletions lib/src/alert_dialog/show_ok_cancel_alert_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Future<OkCancelResult> showOkCancelAlertDialog({
VerticalDirection actionsOverflowDirection = VerticalDirection.up,
bool fullyCapitalizedForMaterial = true,
bool canPop = true,
PopInvokedCallback? onPopInvoked,
PopInvokedWithResultCallback<OkCancelResult>? onPopInvokedWithResult,
AdaptiveDialogBuilder? builder,
RouteSettings? routeSettings,
}) async {
Expand All @@ -55,7 +55,7 @@ Future<OkCancelResult> showOkCancelAlertDialog({
actionsOverflowDirection: actionsOverflowDirection,
fullyCapitalizedForMaterial: fullyCapitalizedForMaterial,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
builder: builder,
actions: [
AlertDialogAction(
Expand Down
6 changes: 3 additions & 3 deletions lib/src/modal_action_sheet/cupertino_modal_action_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CupertinoModalActionSheet<T> extends StatelessWidget {
this.message,
this.cancelLabel,
required this.canPop,
required this.onPopInvoked,
required this.onPopInvokedWithResult,
});

final ActionCallback<T> onPressed;
Expand All @@ -23,15 +23,15 @@ class CupertinoModalActionSheet<T> extends StatelessWidget {
final String? message;
final String? cancelLabel;
final bool canPop;
final PopInvokedCallback? onPopInvoked;
final PopInvokedWithResultCallback<T>? onPopInvokedWithResult;

@override
Widget build(BuildContext context) {
final title = this.title;
final message = this.message;
return PopScope(
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
child: MediaQuery.withClampedTextScaling(
minScaleFactor: 1,
child: CupertinoActionSheet(
Expand Down
6 changes: 3 additions & 3 deletions lib/src/modal_action_sheet/material_modal_action_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MaterialModalActionSheet<T> extends StatelessWidget {
this.message,
this.materialConfiguration,
required this.canPop,
required this.onPopInvoked,
required this.onPopInvokedWithResult,
});

final ActionCallback<T> onPressed;
Expand All @@ -21,7 +21,7 @@ class MaterialModalActionSheet<T> extends StatelessWidget {
final String? message;
final MaterialModalActionSheetConfiguration? materialConfiguration;
final bool canPop;
final PopInvokedCallback? onPopInvoked;
final PopInvokedWithResultCallback<T>? onPopInvokedWithResult;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -90,7 +90,7 @@ class MaterialModalActionSheet<T> extends StatelessWidget {
);
return PopScope(
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
child: body,
);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/modal_action_sheet/modal_action_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Future<T?> showModalActionSheet<T>({
bool useRootNavigator = true,
MaterialModalActionSheetConfiguration? materialConfiguration,
bool canPop = true,
PopInvokedCallback? onPopInvoked,
PopInvokedWithResultCallback<T>? onPopInvokedWithResult,
AdaptiveDialogBuilder? builder,
RouteSettings? routeSettings,
}) {
Expand All @@ -50,7 +50,7 @@ Future<T?> showModalActionSheet<T>({
actions: actions,
materialConfiguration: materialConfiguration,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
);
return builder == null ? sheet : builder(context, sheet);
},
Expand All @@ -67,7 +67,7 @@ Future<T?> showModalActionSheet<T>({
actions: actions,
cancelLabel: cancelLabel,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
);
return builder == null ? sheet : builder(context, sheet);
},
Expand Down
5 changes: 3 additions & 2 deletions lib/src/text_input_dialog/ios_text_input_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,7 +31,7 @@ class IOSTextInputDialog extends StatefulWidget {
final AdaptiveStyle style;
final bool useRootNavigator;
final bool canPop;
final PopInvokedCallback? onPopInvoked;
final PopInvokedWithResultCallback<List<String>?>? onPopInvokedWithResult;
final bool autoSubmit;
}

Expand Down Expand Up @@ -114,6 +114,7 @@ class _IOSTextInputDialogState extends State<IOSTextInputDialog> {
final validationMessage = _validationMessage;
return PopScope(
canPop: widget.canPop,
onPopInvokedWithResult: widget.onPopInvokedWithResult,
child: CupertinoAlertDialog(
title: title == null ? null : Text(title),
content: Column(
Expand Down
4 changes: 2 additions & 2 deletions lib/src/text_input_dialog/macos_text_input_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +34,7 @@ class MacOSTextInputDialog extends StatefulWidget {
final AdaptiveStyle style;
final bool useRootNavigator;
final bool canPop;
final PopInvokedCallback? onPopInvoked;
final PopInvokedWithResultCallback<List<String>?>? onPopInvokedWithResult;
final bool autoSubmit;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/src/text_input_dialog/material_text_input_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,7 +35,7 @@ class MaterialTextInputDialog extends StatefulWidget {
final bool useRootNavigator;
final bool fullyCapitalized;
final bool canPop;
final PopInvokedCallback? onPopInvoked;
final PopInvokedWithResultCallback<List<String>?>? onPopInvokedWithResult;
final bool autoSubmit;
}

Expand Down Expand Up @@ -95,6 +95,7 @@ class _MaterialTextInputDialogState extends State<MaterialTextInputDialog> {
);
return PopScope(
canPop: widget.canPop,
onPopInvokedWithResult: widget.onPopInvokedWithResult,
child: Form(
key: _formKey,
child: AlertDialog(
Expand Down
8 changes: 3 additions & 5 deletions lib/src/text_input_dialog/show_text_answer_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Future<bool> showTextAnswerDialog({
VerticalDirection actionsOverflowDirection = VerticalDirection.up,
bool fullyCapitalizedForMaterial = true,
bool canPop = true,
PopInvokedCallback? onPopInvoked,
PopInvokedWithResultCallback<List<String>?>? onPopInvokedWithResult,
bool autoSubmit = false,
bool isCaseSensitive = true,
AdaptiveDialogBuilder? builder,
Expand All @@ -42,7 +42,7 @@ Future<bool> showTextAnswerDialog({
actionsOverflowDirection: actionsOverflowDirection,
fullyCapitalizedForMaterial: fullyCapitalizedForMaterial,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
autoSubmit: autoSubmit,
builder: builder,
);
Expand All @@ -66,8 +66,6 @@ Future<bool> showTextAnswerDialog({
barrierDismissible: barrierDismissible,
useRootNavigator: useRootNavigator,
fullyCapitalizedForMaterial: fullyCapitalizedForMaterial,
canPop: canPop,
onPopInvoked: onPopInvoked,
builder: builder,
);
return result == OkCancelResult.ok
Expand All @@ -90,7 +88,7 @@ Future<bool> showTextAnswerDialog({
actionsOverflowDirection: actionsOverflowDirection,
fullyCapitalizedForMaterial: fullyCapitalizedForMaterial,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
autoSubmit: autoSubmit,
builder: builder,
)
Expand Down
8 changes: 4 additions & 4 deletions lib/src/text_input_dialog/show_text_input_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Future<List<String>?> showTextInputDialog({
VerticalDirection actionsOverflowDirection = VerticalDirection.up,
bool fullyCapitalizedForMaterial = true,
bool canPop = true,
PopInvokedCallback? onPopInvoked,
PopInvokedWithResultCallback<List<String>?>? onPopInvokedWithResult,
bool autoSubmit = false,
AdaptiveDialogBuilder? builder,
RouteSettings? routeSettings,
Expand All @@ -52,7 +52,7 @@ Future<List<String>?> showTextInputDialog({
style: adaptiveStyle,
useRootNavigator: useRootNavigator,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
autoSubmit: autoSubmit,
);
return builder == null ? dialog : builder(context, dialog);
Expand All @@ -75,7 +75,7 @@ Future<List<String>?> showTextInputDialog({
style: adaptiveStyle,
useRootNavigator: useRootNavigator,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
autoSubmit: autoSubmit,
),
);
Expand Down Expand Up @@ -103,7 +103,7 @@ Future<List<String>?> showTextInputDialog({
useRootNavigator: useRootNavigator,
fullyCapitalized: fullyCapitalizedForMaterial,
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
autoSubmit: autoSubmit,
);
return builder == null ? dialog : builder(context, dialog);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 34f65a1

Please sign in to comment.