Skip to content

Commit

Permalink
Remove accessibleNavigation reference from BottomSheet (#121132)
Browse files Browse the repository at this point in the history
Remove accessibleNavigation reference from BottomSheet
  • Loading branch information
bleroux authored Feb 24, 2023
1 parent dfe7f84 commit 5d99748
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
4 changes: 1 addition & 3 deletions packages/flutter/lib/src/material/bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,8 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
onDragEnd: handleDragEnd,
),
builder: (BuildContext context, Widget? child) {
// Disable the initial animation when accessible navigation is on so
// that the semantics are added to the tree at the correct time.
final double animationValue = animationCurve.transform(
MediaQuery.accessibleNavigationOf(context) ? 1.0 : widget.route.animation!.value,
widget.route.animation!.value,
);
return Semantics(
scopesRoute: true,
Expand Down
32 changes: 27 additions & 5 deletions packages/flutter/test/material/bottom_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ void main() {
await tester.pumpWidget(Container());
});


testWidgets('Swiping down a BottomSheet should dismiss it by default', (WidgetTester tester) async {

final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
bool showBottomSheetThenCalled = false;

Expand Down Expand Up @@ -128,7 +126,6 @@ void main() {
});

testWidgets('Swiping down a BottomSheet should not dismiss it when enableDrag is false', (WidgetTester tester) async {

final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
bool showBottomSheetThenCalled = false;

Expand Down Expand Up @@ -369,6 +366,32 @@ void main() {
expect(find.text('BottomSheet'), findsNothing);
});

// Regression test for https://github.com/flutter/flutter/issues/121098
testWidgets('Verify that accessibleNavigation has no impact on the BottomSheet animation', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
builder: (BuildContext context, Widget? child) {
return MediaQuery(
data: const MediaQueryData(accessibleNavigation: true),
child: child!,
);
},
home: const Center(child: Text('Test')),
));

await tester.pump();
expect(find.text('BottomSheet'), findsNothing);

final BuildContext homeContext = tester.element(find.text('Test'));
showModalBottomSheet<void>(
context: homeContext,
builder: (BuildContext context) => const Text('BottomSheet'),
);
await tester.pump();

await checkNonLinearAnimation(tester);
await tester.pumpAndSettle();
});

testWidgets('Tapping outside a modal BottomSheet should not dismiss it when isDismissible=false', (WidgetTester tester) async {
late BuildContext savedContext;

Expand Down Expand Up @@ -841,7 +864,7 @@ void main() {
expect(modalBarrier.color, barrierColor);
});

testWidgets('BottomSheet uses fallback values in maretial3',
testWidgets('BottomSheet uses fallback values in material3',
(WidgetTester tester) async {
const Color surfaceColor = Colors.pink;
const Color surfaceTintColor = Colors.blue;
Expand Down Expand Up @@ -891,7 +914,6 @@ void main() {
),
));


showModalBottomSheet<void>(
context: scaffoldKey.currentContext!,
builder: (BuildContext context) {
Expand Down

0 comments on commit 5d99748

Please sign in to comment.