Style: Rename pageBuilder with builder in showCupertinoSheet (#170625)

Style: Rename pageBuilder with builder in showCupertinoSheet
fixes: #169831

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
This commit is contained in:
Kishan Rathore 2025-07-10 23:52:01 +05:30 committed by GitHub
parent d78fc7d940
commit 07aaa8f2aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 49 additions and 6 deletions

View File

@ -428,4 +428,27 @@ transforms:
minSize:
kind: fragment
value: 'arguments[minSize]'
# Changes made in https://github.com/flutter/flutter/pull/170625
- title: "Migrate to 'builder'"
date: 2025-06-14
element:
uris: [ 'cupertino.dart' ]
function: 'showCupertinoSheet'
oneOf:
- if: "pageBuilder != ''"
changes:
- kind: 'addParameter'
index: 3
name: 'builder'
style: optional_named
argumentValue:
expression: '{% pageBuilder %}'
requiredIf: "pageBuilder != ''"
- kind: 'removeParameter'
name: 'pageBuilder'
variables:
pageBuilder:
kind: fragment
value: 'arguments[pageBuilder]'
# Before adding a new fix: read instructions at the top of this file.

View File

@ -140,16 +140,24 @@ final Animatable<double> _kScaleTween = Tween<double>(begin: 1.0, end: 1.0 - _kS
/// * <https://developer.apple.com/design/human-interface-guidelines/sheets>
Future<T?> showCupertinoSheet<T>({
required BuildContext context,
required WidgetBuilder pageBuilder,
@Deprecated(
'Use builder instead. '
'This feature was deprecated after v3.33.0-0.2.pre.',
)
WidgetBuilder? pageBuilder,
WidgetBuilder? builder,
bool useNestedNavigation = false,
bool enableDrag = true,
}) {
final WidgetBuilder builder;
assert(pageBuilder != null || builder != null);
final WidgetBuilder? effectivePageBuilder = builder ?? pageBuilder;
final WidgetBuilder widgetBuilder;
final GlobalKey<NavigatorState> nestedNavigatorKey = GlobalKey<NavigatorState>();
if (!useNestedNavigation) {
builder = pageBuilder;
widgetBuilder = effectivePageBuilder!;
} else {
builder = (BuildContext context) {
widgetBuilder = (BuildContext context) {
return NavigatorPopHandler(
onPopWithResult: (T? result) {
nestedNavigatorKey.currentState!.maybePop();
@ -169,7 +177,7 @@ Future<T?> showCupertinoSheet<T>({
}
Navigator.of(context, rootNavigator: true).pop(result);
},
child: pageBuilder(context),
child: effectivePageBuilder!(context),
);
},
),
@ -183,7 +191,7 @@ Future<T?> showCupertinoSheet<T>({
return Navigator.of(
context,
rootNavigator: true,
).push<T>(CupertinoSheetRoute<T>(builder: builder, enableDrag: enableDrag));
).push<T>(CupertinoSheetRoute<T>(builder: widgetBuilder, enableDrag: enableDrag));
}
/// Provides an iOS-style sheet transition.

View File

@ -289,4 +289,10 @@ void main() {
// https://github.com/flutter/flutter/pull/161295
CupertinoButton(minSize: 60.0);
// https://github.com/flutter/flutter/pull/170625
showCupertinoSheet(
context: context,
pageBuilder: (BuildContext context) => Container(),
);
}

View File

@ -307,4 +307,10 @@ void main() {
// https://github.com/flutter/flutter/pull/161295
CupertinoButton(minimumSize: Size(60.0, 60.0));
// https://github.com/flutter/flutter/pull/170625
showCupertinoSheet(
context: context,
builder: (BuildContext context) => Container(),
);
}