Repository: flutter/flutter
File: packages/flutter/test/material/bottom_sheet_test.dart (Dart)

Code before:
            return GestureDetector(
              onTap: () {
                showModalBottomSheet<void>(
                  context: context,
                  sheetAnimationStyle: const AnimationStyle(
                    curve: Curves.easeIn,
                    reverseCurve: Curves.easeOut,
                  ),
                  builder: (_) => const SizedBox(height: 200),
                );
              },
              child: const Text('X'),
            );
          },
        ),
      ),
    );

    await tester.tap(find.text('X'));
    await tester.pump();

    final route = observer.lastRoute! as ModalBottomSheetRoute;

    final proxy = route.animation! as ProxyAnimation;

    final curved = proxy.parent! as CurvedAnimation;

    expect(curved.curve, same(Curves.easeIn));
    expect(curved.reverseCurve, same(Curves.easeOut));
  });
}

class _TestPage extends StatelessWidget {
  const _TestPage({this.useRootNavigator});

  final bool? useRootNavigator;

  @override
  Widget build(BuildContext context) {
    return Center(
      child: TextButton(
        child: const Text('Show bottom sheet'),
        onPressed: () {
          if (useRootNavigator != null) {
            showModalBottomSheet<void>(
              useRootNavigator: useRootNavigator!,
              context: context,
              builder: (_) => const Text('Modal bottom sheet'),
            );
          } else {
            showModalBottomSheet<void>(

Review comment (suggestion):
Not a big fan of using type casts to regression test instead of testing the actual widget behavior (e.g that the animation follows the passed-in curve rather than a default, etc.).

Code after:
                  showModalBottomSheet<void>(
                    context: context,
                    sheetAnimationStyle: const AnimationStyle(curve: Curves.linear),
                    builder: (BuildContext context) {
                      return SizedBox.expand(
                        key: sheetKey,
                        child: FilledButton(
                          onPressed: () {
                            Navigator.pop(context);
                          },
                          child: const Text('Close'),
                        ),
                      );
                    },
                  );
                },
                child: const Text('X'),
              );
            },
          ),
        ),
      ),
    );

    await tester.tap(find.text('X'));
    await tester.pump();

    // Advance the animation by 50ms.
    await tester.pump(const Duration(milliseconds: 50));
    final double openExtent1 = tester.getTopLeft(find.byKey(sheetKey)).dy;

    // Advance the animation by an additional 50ms.
    await tester.pump(const Duration(milliseconds: 50));
    final double openExtent2 = tester.getTopLeft(find.byKey(sheetKey)).dy;

    // Advance the animation by an additional 50ms.
    await tester.pump(const Duration(milliseconds: 50));
    final double openExtent3 = tester.getTopLeft(find.byKey(sheetKey)).dy;

    // For the linear curve, the distance covered in each time interval should
    // be the same.
    expect(openExtent1 - openExtent2, closeTo(openExtent2 - openExtent3, 0.1));
    await tester.pumpAndSettle();

    // Dismiss the bottom sheet.
    await tester.tap(find.widgetWithText(FilledButton, 'Close'));
    await tester.pumpAndSettle();
  });

  testWidgets('ModalBottomSheet uses AnimationStyle reverseCurve', (WidgetTester tester) async {
    final Key sheetKey = UniqueKey();