Skip to content

Commit 34f65a1

Browse files
committed
Fix deprecated API use (ButtonBar, PopInvokedCallback)
1 parent cd64019 commit 34f65a1

16 files changed

+50
-40
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.2.0
2+
3+
- Fix deprecated API use (ButtonBar, PopInvokedCallback)
4+
- `onPopInvoked` should be migrated to `onPopInvokedWithResult`
5+
- https://docs.flutter.dev/release/breaking-changes/popscope-with-result
6+
17
## 2.1.0
28

39
- Add `spellCheckConfiguration` to `DialogTextField`

example/lib/pages/alert_page.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class AlertPage extends StatelessWidget {
4141
title: 'Title',
4242
message: 'This is message.',
4343
canPop: false,
44+
onPopInvokedWithResult: (didPop, result) {
45+
logger.info('didPop: $didPop, result: $result');
46+
},
4447
);
4548
assert(result == OkCancelResult.ok);
4649
logger.info(result);

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ packages:
2020
path: ".."
2121
relative: true
2222
source: path
23-
version: "2.1.0"
23+
version: "2.1.1"
2424
analyzer:
2525
dependency: transitive
2626
description:

lib/src/alert_dialog/show_alert_dialog.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Future<T?> showAlertDialog<T>({
2929
VerticalDirection actionsOverflowDirection = VerticalDirection.up,
3030
bool fullyCapitalizedForMaterial = true,
3131
bool canPop = true,
32-
PopInvokedCallback? onPopInvoked,
32+
PopInvokedWithResultCallback<T>? onPopInvokedWithResult,
3333
AdaptiveDialogBuilder? builder,
3434
Widget? macOSApplicationIcon,
3535
RouteSettings? routeSettings,
@@ -53,7 +53,7 @@ Future<T?> showAlertDialog<T>({
5353
style: style,
5454
useRootNavigator: useRootNavigator,
5555
canPop: canPop,
56-
onPopInvoked: onPopInvoked,
56+
onPopInvokedWithResult: onPopInvokedWithResult,
5757
builder: builder,
5858
routeSettings: routeSettings,
5959
);
@@ -74,7 +74,7 @@ Future<T?> showAlertDialog<T>({
7474
builder: (context) {
7575
final dialog = PopScope(
7676
canPop: canPop,
77-
onPopInvoked: onPopInvoked,
77+
onPopInvokedWithResult: onPopInvokedWithResult,
7878
child: CupertinoAlertDialog(
7979
title: titleText,
8080
content: messageText,
@@ -111,7 +111,7 @@ Future<T?> showAlertDialog<T>({
111111
final Widget dialog = MacThemeWrapper(
112112
child: PopScope(
113113
canPop: canPop,
114-
onPopInvoked: onPopInvoked,
114+
onPopInvokedWithResult: onPopInvokedWithResult,
115115
child: MacosAlertDialog(
116116
title: titleText ?? const SizedBox.shrink(),
117117
message: messageText ?? const SizedBox.shrink(),
@@ -140,7 +140,7 @@ Future<T?> showAlertDialog<T>({
140140
builder: (context) {
141141
final dialog = PopScope(
142142
canPop: canPop,
143-
onPopInvoked: onPopInvoked,
143+
onPopInvokedWithResult: onPopInvokedWithResult,
144144
child: AlertDialog(
145145
title: titleText,
146146
content: messageText,

lib/src/alert_dialog/show_confirmation_dialog.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Future<T?> showConfirmationDialog<T>({
3333
bool shrinkWrap = true,
3434
bool fullyCapitalizedForMaterial = true,
3535
bool canPop = true,
36-
PopInvokedCallback? onPopInvoked,
36+
PopInvokedWithResultCallback<T>? onPopInvokedWithResult,
3737
AdaptiveDialogBuilder? builder,
3838
RouteSettings? routeSettings,
3939
bool toggleable = true,
@@ -66,7 +66,7 @@ Future<T?> showConfirmationDialog<T>({
6666
shrinkWrap: shrinkWrap,
6767
fullyCapitalized: fullyCapitalizedForMaterial,
6868
canPop: canPop,
69-
onPopInvoked: onPopInvoked,
69+
onPopInvokedWithResult: onPopInvokedWithResult,
7070
toggleable: toggleable,
7171
);
7272
return builder == null ? dialog : builder(context, dialog);
@@ -81,7 +81,7 @@ Future<T?> showConfirmationDialog<T>({
8181
style: style,
8282
useRootNavigator: useRootNavigator,
8383
canPop: canPop,
84-
onPopInvoked: onPopInvoked,
84+
onPopInvokedWithResult: onPopInvokedWithResult,
8585
builder: builder,
8686
routeSettings: routeSettings,
8787
);
@@ -101,7 +101,7 @@ class _ConfirmationMaterialDialog<T> extends StatefulWidget {
101101
required this.shrinkWrap,
102102
required this.fullyCapitalized,
103103
required this.canPop,
104-
required this.onPopInvoked,
104+
required this.onPopInvokedWithResult,
105105
required this.toggleable,
106106
});
107107

@@ -116,7 +116,7 @@ class _ConfirmationMaterialDialog<T> extends StatefulWidget {
116116
final bool shrinkWrap;
117117
final bool fullyCapitalized;
118118
final bool canPop;
119-
final PopInvokedCallback? onPopInvoked;
119+
final PopInvokedWithResultCallback<T>? onPopInvokedWithResult;
120120
final bool toggleable;
121121

122122
@override
@@ -144,6 +144,7 @@ class _ConfirmationMaterialDialogState<T>
144144
final message = widget.message;
145145
return PopScope(
146146
canPop: widget.canPop,
147+
onPopInvokedWithResult: widget.onPopInvokedWithResult,
147148
child: Dialog(
148149
child: Column(
149150
mainAxisSize: MainAxisSize.min,

lib/src/alert_dialog/show_ok_alert_dialog.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Future<OkCancelResult> showOkAlertDialog({
2222
VerticalDirection actionsOverflowDirection = VerticalDirection.up,
2323
bool fullyCapitalizedForMaterial = true,
2424
bool canPop = true,
25-
PopInvokedCallback? onPopInvoked,
25+
PopInvokedWithResultCallback<OkCancelResult>? onPopInvokedWithResult,
2626
AdaptiveDialogBuilder? builder,
2727
RouteSettings? routeSettings,
2828
}) async {
@@ -41,7 +41,7 @@ Future<OkCancelResult> showOkAlertDialog({
4141
actionsOverflowDirection: actionsOverflowDirection,
4242
fullyCapitalizedForMaterial: fullyCapitalizedForMaterial,
4343
canPop: canPop,
44-
onPopInvoked: onPopInvoked,
44+
onPopInvokedWithResult: onPopInvokedWithResult,
4545
builder: builder,
4646
actions: [
4747
AlertDialogAction(

lib/src/alert_dialog/show_ok_cancel_alert_dialog.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Future<OkCancelResult> showOkCancelAlertDialog({
3131
VerticalDirection actionsOverflowDirection = VerticalDirection.up,
3232
bool fullyCapitalizedForMaterial = true,
3333
bool canPop = true,
34-
PopInvokedCallback? onPopInvoked,
34+
PopInvokedWithResultCallback<OkCancelResult>? onPopInvokedWithResult,
3535
AdaptiveDialogBuilder? builder,
3636
RouteSettings? routeSettings,
3737
}) async {
@@ -55,7 +55,7 @@ Future<OkCancelResult> showOkCancelAlertDialog({
5555
actionsOverflowDirection: actionsOverflowDirection,
5656
fullyCapitalizedForMaterial: fullyCapitalizedForMaterial,
5757
canPop: canPop,
58-
onPopInvoked: onPopInvoked,
58+
onPopInvokedWithResult: onPopInvokedWithResult,
5959
builder: builder,
6060
actions: [
6161
AlertDialogAction(

lib/src/modal_action_sheet/cupertino_modal_action_sheet.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CupertinoModalActionSheet<T> extends StatelessWidget {
1414
this.message,
1515
this.cancelLabel,
1616
required this.canPop,
17-
required this.onPopInvoked,
17+
required this.onPopInvokedWithResult,
1818
});
1919

2020
final ActionCallback<T> onPressed;
@@ -23,15 +23,15 @@ class CupertinoModalActionSheet<T> extends StatelessWidget {
2323
final String? message;
2424
final String? cancelLabel;
2525
final bool canPop;
26-
final PopInvokedCallback? onPopInvoked;
26+
final PopInvokedWithResultCallback<T>? onPopInvokedWithResult;
2727

2828
@override
2929
Widget build(BuildContext context) {
3030
final title = this.title;
3131
final message = this.message;
3232
return PopScope(
3333
canPop: canPop,
34-
onPopInvoked: onPopInvoked,
34+
onPopInvokedWithResult: onPopInvokedWithResult,
3535
child: MediaQuery.withClampedTextScaling(
3636
minScaleFactor: 1,
3737
child: CupertinoActionSheet(

lib/src/modal_action_sheet/material_modal_action_sheet.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class MaterialModalActionSheet<T> extends StatelessWidget {
1212
this.message,
1313
this.materialConfiguration,
1414
required this.canPop,
15-
required this.onPopInvoked,
15+
required this.onPopInvokedWithResult,
1616
});
1717

1818
final ActionCallback<T> onPressed;
@@ -21,7 +21,7 @@ class MaterialModalActionSheet<T> extends StatelessWidget {
2121
final String? message;
2222
final MaterialModalActionSheetConfiguration? materialConfiguration;
2323
final bool canPop;
24-
final PopInvokedCallback? onPopInvoked;
24+
final PopInvokedWithResultCallback<T>? onPopInvokedWithResult;
2525

2626
@override
2727
Widget build(BuildContext context) {
@@ -90,7 +90,7 @@ class MaterialModalActionSheet<T> extends StatelessWidget {
9090
);
9191
return PopScope(
9292
canPop: canPop,
93-
onPopInvoked: onPopInvoked,
93+
onPopInvokedWithResult: onPopInvokedWithResult,
9494
child: body,
9595
);
9696
}

lib/src/modal_action_sheet/modal_action_sheet.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Future<T?> showModalActionSheet<T>({
2424
bool useRootNavigator = true,
2525
MaterialModalActionSheetConfiguration? materialConfiguration,
2626
bool canPop = true,
27-
PopInvokedCallback? onPopInvoked,
27+
PopInvokedWithResultCallback<T>? onPopInvokedWithResult,
2828
AdaptiveDialogBuilder? builder,
2929
RouteSettings? routeSettings,
3030
}) {
@@ -50,7 +50,7 @@ Future<T?> showModalActionSheet<T>({
5050
actions: actions,
5151
materialConfiguration: materialConfiguration,
5252
canPop: canPop,
53-
onPopInvoked: onPopInvoked,
53+
onPopInvokedWithResult: onPopInvokedWithResult,
5454
);
5555
return builder == null ? sheet : builder(context, sheet);
5656
},
@@ -67,7 +67,7 @@ Future<T?> showModalActionSheet<T>({
6767
actions: actions,
6868
cancelLabel: cancelLabel,
6969
canPop: canPop,
70-
onPopInvoked: onPopInvoked,
70+
onPopInvokedWithResult: onPopInvokedWithResult,
7171
);
7272
return builder == null ? sheet : builder(context, sheet);
7373
},

0 commit comments

Comments
 (0)