Resolved contradictory documentation of showGeneralDialog and default value of 'barrierLabel' argument (#78890)

This commit is contained in:
Tapaswi Satyapanthi
2021-03-25 06:29:04 +05:30
committed by GitHub
parent d3ee5ace29
commit dbf7fab0a9
2 changed files with 37 additions and 2 deletions

View File

@@ -1870,11 +1870,11 @@ class RawDialogRoute<T> extends PopupRoute<T> {
///
/// The `barrierDismissible` argument is used to determine whether this route
/// can be dismissed by tapping the modal barrier. This argument defaults
/// to true. If `barrierDismissible` is true, a non-null `barrierLabel` must be
/// to false. If `barrierDismissible` is true, a non-null `barrierLabel` must be
/// provided.
///
/// The `barrierLabel` argument is the semantic label used for a dismissible
/// barrier. This argument defaults to "Dismiss".
/// barrier. This argument defaults to `null`.
///
/// The `barrierColor` argument is the color used for the modal barrier. This
/// argument defaults to `Color(0x80000000)`.

View File

@@ -1015,6 +1015,41 @@ void main() {
expect(find.byType(ModalBarrier), findsNWidgets(1));
});
testWidgets('showGeneralDialog uses null as a barrierLabel by default', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Builder(
builder: (BuildContext context) {
return ElevatedButton(
onPressed: () {
showGeneralDialog<void>(
context: context,
transitionDuration: Duration.zero,
pageBuilder: (BuildContext innerContext, _, __) {
return const SizedBox();
},
);
},
child: const Text('Show Dialog'),
);
},
),
));
// Open the dialog.
await tester.tap(find.byType(ElevatedButton));
await tester.pump();
expect(find.byType(ModalBarrier), findsNWidgets(2));
final ModalBarrier barrier = find.byType(ModalBarrier).evaluate().last.widget as ModalBarrier;
expect(barrier.semanticsLabel, same(null));
// Close the dialog.
final StatefulElement navigatorElement = find.byType(Navigator).evaluate().last as StatefulElement;
final NavigatorState navigatorState = navigatorElement.state as NavigatorState;
navigatorState.pop();
await tester.pumpAndSettle();
expect(find.byType(ModalBarrier), findsNWidgets(1));
});
testWidgets('showGeneralDialog uses root navigator by default', (WidgetTester tester) async {
final DialogObserver rootObserver = DialogObserver();
final DialogObserver nestedObserver = DialogObserver();