Skip to content

Commit 300c5d8

Browse files
authored
Revert "Proposal to add barrier configs for showDatePicker, showTimePicker and showAboutDialog." (flutter#131278)
Reverts flutter#130484. /cc @ronnnnn Example failure: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20framework_tests_libraries/12185/overview <details> <summary>Failure logs...</summary> ``` 04:51 +5379 ~18: /Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart: Barrier dismissible Barrier is dismissible with default parameter ��� EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ����������������������������������������������������� The following TestFailure was thrown running a test: Expected: <1> Actual: <2> When the exception was thrown, this was the stack: #4 main.<anonymous closure>.<anonymous closure> (file:///Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart:776:7) <asynchronous suspension> #5 testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:165:15) <asynchronous suspension> #6 TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1008:5) <asynchronous suspension> <asynchronous suspension> (elided one frame from package:stack_trace) This was caught by the test expectation on the following line: file:///Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart line 776 The test description was: Barrier is dismissible with default parameter ���������������������������������������������������������������������������������������������������� 04:51 +5379 ~18 -1: /Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart: Barrier dismissible Barrier is dismissible with default parameter [E] Test failed. See exception logs above. The test description was: Barrier is dismissible with default parameter To run this test again: /Volumes/Work/s/w/ir/x/w/flutter/bin/cache/dart-sdk/bin/dart test /Volumes/Work/s/w/ir/x/w/flutter/packages/flutter/test/material/about_test.dart -p vm --plain-name 'Barrier dismissible Barrier is dismissible with default parameter' ``` </details>
1 parent 2da3bdd commit 300c5d8

File tree

7 files changed

+14
-564
lines changed

7 files changed

+14
-564
lines changed

packages/flutter/lib/src/material/about.dart

+3-9
Original file line numberDiff line numberDiff line change
@@ -170,28 +170,22 @@ class AboutListTile extends StatelessWidget {
170170
/// The licenses shown on the [LicensePage] are those returned by the
171171
/// [LicenseRegistry] API, which can be used to add more licenses to the list.
172172
///
173-
/// The [context], [barrierDismissible], [barrierColor], [barrierLabel],
174-
/// [useRootNavigator], [routeSettings] and [anchorPoint] arguments are
175-
/// passed to [showDialog], the documentation for which discusses how it is used.
173+
/// The [context], [useRootNavigator], [routeSettings] and [anchorPoint]
174+
/// arguments are passed to [showDialog], the documentation for which discusses
175+
/// how it is used.
176176
void showAboutDialog({
177177
required BuildContext context,
178178
String? applicationName,
179179
String? applicationVersion,
180180
Widget? applicationIcon,
181181
String? applicationLegalese,
182182
List<Widget>? children,
183-
bool barrierDismissible = true,
184-
Color? barrierColor,
185-
String? barrierLabel,
186183
bool useRootNavigator = true,
187184
RouteSettings? routeSettings,
188185
Offset? anchorPoint,
189186
}) {
190187
showDialog<void>(
191188
context: context,
192-
barrierDismissible: barrierDismissible,
193-
barrierColor: barrierColor,
194-
barrierLabel: barrierLabel,
195189
useRootNavigator: useRootNavigator,
196190
builder: (BuildContext context) {
197191
return AboutDialog(

packages/flutter/lib/src/material/date_picker.dart

+6-20
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,9 @@ const double _kMaxTextScaleFactor = 1.3;
113113
/// [locale] and [textDirection] are non-null, [textDirection] overrides the
114114
/// direction chosen for the [locale].
115115
///
116-
/// The [context], [barrierDismissible], [barrierColor], [barrierLabel],
117-
/// [useRootNavigator] and [routeSettings] arguments are passed to [showDialog],
118-
/// the documentation for which discusses how it is used.
119-
/// [context], [barrierDismissible] and [useRootNavigator] must be non-null.
116+
/// The [context], [useRootNavigator] and [routeSettings] arguments are passed to
117+
/// [showDialog], the documentation for which discusses how it is used. [context]
118+
/// and [useRootNavigator] must be non-null.
120119
///
121120
/// The [builder] parameter can be used to wrap the dialog widget
122121
/// to add inherited widgets like [Theme].
@@ -170,9 +169,6 @@ Future<DateTime?> showDatePicker({
170169
String? cancelText,
171170
String? confirmText,
172171
Locale? locale,
173-
bool barrierDismissible = true,
174-
Color? barrierColor,
175-
String? barrierLabel,
176172
bool useRootNavigator = true,
177173
RouteSettings? routeSettings,
178174
TextDirection? textDirection,
@@ -247,9 +243,6 @@ Future<DateTime?> showDatePicker({
247243

248244
return showDialog<DateTime>(
249245
context: context,
250-
barrierDismissible: barrierDismissible,
251-
barrierColor: barrierColor,
252-
barrierLabel: barrierLabel,
253246
useRootNavigator: useRootNavigator,
254247
routeSettings: routeSettings,
255248
builder: (BuildContext context) {
@@ -974,10 +967,9 @@ class _DatePickerHeader extends StatelessWidget {
974967
/// [locale] and [textDirection] are non-null, [textDirection] overrides the
975968
/// direction chosen for the [locale].
976969
///
977-
/// The [context], [barrierDismissible], [barrierColor], [barrierLabel],
978-
/// [useRootNavigator] and [routeSettings] arguments are passed to [showDialog],
979-
/// the documentation for which discusses how it is used.
980-
/// [context], [barrierDismissible] and [useRootNavigator] must be non-null.
970+
/// The [context], [useRootNavigator] and [routeSettings] arguments are passed
971+
/// to [showDialog], the documentation for which discusses how it is used.
972+
/// [context] and [useRootNavigator] must be non-null.
981973
///
982974
/// The [builder] parameter can be used to wrap the dialog widget
983975
/// to add inherited widgets like [Theme].
@@ -1030,9 +1022,6 @@ Future<DateTimeRange?> showDateRangePicker({
10301022
String? fieldStartLabelText,
10311023
String? fieldEndLabelText,
10321024
Locale? locale,
1033-
bool barrierDismissible = true,
1034-
Color? barrierColor,
1035-
String? barrierLabel,
10361025
bool useRootNavigator = true,
10371026
RouteSettings? routeSettings,
10381027
TextDirection? textDirection,
@@ -1111,9 +1100,6 @@ Future<DateTimeRange?> showDateRangePicker({
11111100

11121101
return showDialog<DateTimeRange>(
11131102
context: context,
1114-
barrierDismissible: barrierDismissible,
1115-
barrierColor: barrierColor,
1116-
barrierLabel: barrierLabel,
11171103
useRootNavigator: useRootNavigator,
11181104
routeSettings: routeSettings,
11191105
useSafeArea: false,

packages/flutter/lib/src/material/dialog.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ Future<T?> showDialog<T>({
14041404
required BuildContext context,
14051405
required WidgetBuilder builder,
14061406
bool barrierDismissible = true,
1407-
Color? barrierColor,
1407+
Color? barrierColor = Colors.black54,
14081408
String? barrierLabel,
14091409
bool useSafeArea = true,
14101410
bool useRootNavigator = true,
@@ -1426,7 +1426,7 @@ Future<T?> showDialog<T>({
14261426
return Navigator.of(context, rootNavigator: useRootNavigator).push<T>(DialogRoute<T>(
14271427
context: context,
14281428
builder: builder,
1429-
barrierColor: barrierColor ?? Colors.black54,
1429+
barrierColor: barrierColor,
14301430
barrierDismissible: barrierDismissible,
14311431
barrierLabel: barrierLabel,
14321432
useSafeArea: useSafeArea,
@@ -1449,7 +1449,7 @@ Future<T?> showAdaptiveDialog<T>({
14491449
required BuildContext context,
14501450
required WidgetBuilder builder,
14511451
bool? barrierDismissible,
1452-
Color? barrierColor,
1452+
Color? barrierColor = Colors.black54,
14531453
String? barrierLabel,
14541454
bool useSafeArea = true,
14551455
bool useRootNavigator = true,

packages/flutter/lib/src/material/time_picker.dart

+2-9
Original file line numberDiff line numberDiff line change
@@ -2874,9 +2874,8 @@ class _TimePickerState extends State<_TimePicker> with RestorationMixin {
28742874
/// ```
28752875
/// {@end-tool}
28762876
///
2877-
/// The [context], [barrierDismissible], [barrierColor], [barrierLabel],
2878-
/// [useRootNavigator] and [routeSettings] arguments are passed to [showDialog],
2879-
/// the documentation for which discusses how it is used.
2877+
/// The [context], [useRootNavigator] and [routeSettings] arguments are passed
2878+
/// to [showDialog], the documentation for which discusses how it is used.
28802879
///
28812880
/// The [builder] parameter can be used to wrap the dialog widget to add
28822881
/// inherited widgets like [Localizations.override], [Directionality], or
@@ -2955,9 +2954,6 @@ Future<TimeOfDay?> showTimePicker({
29552954
required BuildContext context,
29562955
required TimeOfDay initialTime,
29572956
TransitionBuilder? builder,
2958-
bool barrierDismissible = true,
2959-
Color? barrierColor,
2960-
String? barrierLabel,
29612957
bool useRootNavigator = true,
29622958
TimePickerEntryMode initialEntryMode = TimePickerEntryMode.dial,
29632959
String? cancelText,
@@ -2987,9 +2983,6 @@ Future<TimeOfDay?> showTimePicker({
29872983
);
29882984
return showDialog<TimeOfDay>(
29892985
context: context,
2990-
barrierDismissible: barrierDismissible,
2991-
barrierColor: barrierColor,
2992-
barrierLabel: barrierLabel,
29932986
useRootNavigator: useRootNavigator,
29942987
builder: (BuildContext context) {
29952988
return builder == null ? dialog : builder(context, dialog);

packages/flutter/test/material/about_test.dart

-162
Original file line numberDiff line numberDiff line change
@@ -742,160 +742,6 @@ void main() {
742742
expect(nestedObserver.licensePageCount, 0);
743743
});
744744

745-
group('Barrier dismissible', () {
746-
late AboutDialogObserver rootObserver;
747-
748-
setUpAll(() {
749-
rootObserver = AboutDialogObserver();
750-
});
751-
752-
testWidgets('Barrier is dismissible with default parameter', (WidgetTester tester) async {
753-
await tester.pumpWidget(
754-
MaterialApp(
755-
navigatorObservers: <NavigatorObserver>[rootObserver],
756-
home: Material(
757-
child: Center(
758-
child: Builder(
759-
builder: (BuildContext context) {
760-
return ElevatedButton(
761-
child: const Text('X'),
762-
onPressed: () => showAboutDialog(
763-
context: context,
764-
),
765-
);
766-
},
767-
),
768-
),
769-
),
770-
),
771-
);
772-
773-
// Open the dialog.
774-
await tester.tap(find.byType(ElevatedButton));
775-
await tester.pumpAndSettle();
776-
expect(rootObserver.dialogCount, 1);
777-
778-
// Tap on the barrier.
779-
await tester.tapAt(const Offset(10.0, 10.0));
780-
await tester.pumpAndSettle();
781-
expect(rootObserver.dialogCount, 0);
782-
});
783-
784-
testWidgets('Barrier is not dismissible with barrierDismissible is false', (WidgetTester tester) async {
785-
await tester.pumpWidget(
786-
MaterialApp(
787-
navigatorObservers: <NavigatorObserver>[rootObserver],
788-
home: Material(
789-
child: Center(
790-
child: Builder(
791-
builder: (BuildContext context) {
792-
return ElevatedButton(
793-
child: const Text('X'),
794-
onPressed: () => showAboutDialog(
795-
context: context,
796-
barrierDismissible: false
797-
),
798-
);
799-
},
800-
),
801-
),
802-
),
803-
),
804-
);
805-
806-
// Open the dialog.
807-
await tester.tap(find.byType(ElevatedButton));
808-
await tester.pumpAndSettle();
809-
expect(rootObserver.dialogCount, 1);
810-
811-
// Tap on the barrier, which shouldn't do anything this time.
812-
await tester.tapAt(const Offset(10.0, 10.0));
813-
await tester.pumpAndSettle();
814-
expect(rootObserver.dialogCount, 1);
815-
});
816-
});
817-
818-
testWidgets('Barrier color', (WidgetTester tester) async {
819-
await tester.pumpWidget(
820-
MaterialApp(
821-
home: Material(
822-
child: Center(
823-
child: Builder(
824-
builder: (BuildContext context) {
825-
return ElevatedButton(
826-
child: const Text('X'),
827-
onPressed: () => showAboutDialog(
828-
context: context,
829-
),
830-
);
831-
},
832-
),
833-
),
834-
),
835-
),
836-
);
837-
838-
// Open the dialog.
839-
await tester.tap(find.byType(ElevatedButton));
840-
await tester.pumpAndSettle();
841-
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, Colors.black54);
842-
843-
// Dismiss the dialog.
844-
await tester.tapAt(const Offset(10.0, 10.0));
845-
846-
await tester.pumpWidget(
847-
MaterialApp(
848-
home: Material(
849-
child: Center(
850-
child: Builder(
851-
builder: (BuildContext context) {
852-
return ElevatedButton(
853-
child: const Text('X'),
854-
onPressed: () => showAboutDialog(
855-
context: context,
856-
barrierColor: Colors.pink,
857-
),
858-
);
859-
},
860-
),
861-
),
862-
),
863-
),
864-
);
865-
866-
// Open the dialog.
867-
await tester.tap(find.byType(ElevatedButton));
868-
await tester.pumpAndSettle();
869-
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, Colors.pink);
870-
});
871-
872-
testWidgets('Barrier Label', (WidgetTester tester) async {
873-
await tester.pumpWidget(
874-
MaterialApp(
875-
home: Material(
876-
child: Center(
877-
child: Builder(
878-
builder: (BuildContext context) {
879-
return ElevatedButton(
880-
child: const Text('X'),
881-
onPressed: () => showAboutDialog(
882-
context: context,
883-
barrierLabel: 'Custom Label',
884-
),
885-
);
886-
},
887-
),
888-
),
889-
),
890-
),
891-
);
892-
893-
// Open the dialog.
894-
await tester.tap(find.byType(ElevatedButton));
895-
await tester.pumpAndSettle();
896-
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).semanticsLabel, 'Custom Label');
897-
});
898-
899745
testWidgetsWithLeakTracking('showAboutDialog uses root navigator by default', (WidgetTester tester) async {
900746
final AboutDialogObserver rootObserver = AboutDialogObserver();
901747
final AboutDialogObserver nestedObserver = AboutDialogObserver();
@@ -1895,12 +1741,4 @@ class AboutDialogObserver extends NavigatorObserver {
18951741
}
18961742
super.didPush(route, previousRoute);
18971743
}
1898-
1899-
@override
1900-
void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) {
1901-
if (route is DialogRoute) {
1902-
dialogCount--;
1903-
}
1904-
super.didPop(route, previousRoute);
1905-
}
19061744
}

0 commit comments

Comments
 (0)