Remove deprecated showDialog.child (#72532)
This commit is contained in:
parent
5eabfc2447
commit
3abb9e5008
@ -11,6 +11,26 @@
|
|||||||
version: 1
|
version: 1
|
||||||
transforms:
|
transforms:
|
||||||
|
|
||||||
|
# Changes made in https://github.com/flutter/flutter/pull/15303
|
||||||
|
- title: 'Replace child with builder'
|
||||||
|
date: 2020-12-17
|
||||||
|
element:
|
||||||
|
uris: [ 'material.dart' ]
|
||||||
|
function: 'showDialog'
|
||||||
|
changes:
|
||||||
|
- kind: 'addParameter'
|
||||||
|
index: 0
|
||||||
|
name: 'builder'
|
||||||
|
style: optional_named
|
||||||
|
argumentValue:
|
||||||
|
expression: '(context) => {% widget %}'
|
||||||
|
requiredIf: "widget != ''"
|
||||||
|
variables:
|
||||||
|
widget:
|
||||||
|
kind: fragment
|
||||||
|
value: 'arguments[child]'
|
||||||
|
- kind: 'removeParameter'
|
||||||
|
name: 'child'
|
||||||
# Changes made in https://github.com/flutter/flutter/pull/28602
|
# Changes made in https://github.com/flutter/flutter/pull/28602
|
||||||
- title: 'Rename to fromMouseEvent'
|
- title: 'Rename to fromMouseEvent'
|
||||||
date: 2020-12-15
|
date: 2020-12-15
|
||||||
@ -33,7 +53,6 @@ transforms:
|
|||||||
- kind: 'rename'
|
- kind: 'rename'
|
||||||
newName: 'fromMouseEvent'
|
newName: 'fromMouseEvent'
|
||||||
|
|
||||||
|
|
||||||
# Changes made in https://github.com/flutter/flutter/pull/41859
|
# Changes made in https://github.com/flutter/flutter/pull/41859
|
||||||
- title: 'Remove brightness'
|
- title: 'Remove brightness'
|
||||||
date: 2020-12-10
|
date: 2020-12-10
|
||||||
|
@ -967,16 +967,8 @@ Future<T?> showDialog<T>({
|
|||||||
bool useSafeArea = true,
|
bool useSafeArea = true,
|
||||||
bool useRootNavigator = true,
|
bool useRootNavigator = true,
|
||||||
RouteSettings? routeSettings,
|
RouteSettings? routeSettings,
|
||||||
@Deprecated(
|
|
||||||
'Instead of using the "child" argument, return the child from a closure '
|
|
||||||
'provided to the "builder" argument. This will ensure that the BuildContext '
|
|
||||||
'is appropriate for widgets built in the dialog. '
|
|
||||||
'This feature was deprecated after v0.2.3.'
|
|
||||||
)
|
|
||||||
Widget? child,
|
|
||||||
}) {
|
}) {
|
||||||
assert(child == null || builder == null);
|
assert(builder != null);
|
||||||
assert(child != null || builder != null);
|
|
||||||
assert(barrierDismissible != null);
|
assert(barrierDismissible != null);
|
||||||
assert(useSafeArea != null);
|
assert(useSafeArea != null);
|
||||||
assert(useRootNavigator != null);
|
assert(useRootNavigator != null);
|
||||||
@ -986,7 +978,7 @@ Future<T?> showDialog<T>({
|
|||||||
return showGeneralDialog(
|
return showGeneralDialog(
|
||||||
context: context,
|
context: context,
|
||||||
pageBuilder: (BuildContext buildContext, Animation<double> animation, Animation<double> secondaryAnimation) {
|
pageBuilder: (BuildContext buildContext, Animation<double> animation, Animation<double> secondaryAnimation) {
|
||||||
final Widget pageChild = child ?? Builder(builder: builder!);
|
final Widget pageChild = Builder(builder: builder!);
|
||||||
Widget dialog = themes.wrap(pageChild);
|
Widget dialog = themes.wrap(pageChild);
|
||||||
if (useSafeArea) {
|
if (useSafeArea) {
|
||||||
dialog = SafeArea(child: dialog);
|
dialog = SafeArea(child: dialog);
|
||||||
|
@ -217,35 +217,7 @@ void main() {
|
|||||||
expect(materialWidget.shape, customBorder);
|
expect(materialWidget.shape, customBorder);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('showDialog child and builder cannot be simultaneously defined', (WidgetTester tester) async {
|
testWidgets('showDialog builder must be defined', (WidgetTester tester) async {
|
||||||
late BuildContext currentBuildContext;
|
|
||||||
await tester.pumpWidget(
|
|
||||||
MaterialApp(
|
|
||||||
home: Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: Builder(
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
currentBuildContext = context;
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(() async {
|
|
||||||
showDialog<void>(
|
|
||||||
context: currentBuildContext,
|
|
||||||
child: const Text('Child'),
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return const Text('Builder');
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}, throwsAssertionError);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('showDialog child or builder must be defined', (WidgetTester tester) async {
|
|
||||||
late BuildContext currentBuildContext;
|
late BuildContext currentBuildContext;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
|
10
packages/flutter/test_fixes/material.dart
Normal file
10
packages/flutter/test_fixes/material.dart
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// Change made in https://github.com/flutter/flutter/pull/15303
|
||||||
|
showDialog(child: Text('Fix me.'));
|
||||||
|
}
|
10
packages/flutter/test_fixes/material.dart.expect
Normal file
10
packages/flutter/test_fixes/material.dart.expect
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// Change made in https://github.com/flutter/flutter/pull/15303
|
||||||
|
showDialog(builder: (context) => Text('Fix me.'));
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user