mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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:
parent
d78fc7d940
commit
07aaa8f2aa
@ -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.
|
||||
@ -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.
|
||||
|
||||
@ -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(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -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(),
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user