Unverified Commit dbf7fab0 authored by Tapaswi Satyapanthi's avatar Tapaswi Satyapanthi Committed by GitHub

Resolved contradictory documentation of showGeneralDialog and default value of...

Resolved contradictory documentation of showGeneralDialog and default value of 'barrierLabel' argument (#78890)
parent d3ee5ace
......@@ -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)`.
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment