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

Code before:
    testWidgets('backgroundColor', (WidgetTester tester) async {
      await tester.pumpWidget(buildAppBar(contentHeight: 1200.0));

      expect(getAppBarBackgroundColor(tester), defaultColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);

      TestGesture gesture = await tester.startGesture(const Offset(50.0, 400.0));
      await gesture.moveBy(const Offset(0.0, -kToolbarHeight));
      await gesture.up();
      await tester.pumpAndSettle();

      expect(getAppBarBackgroundColor(tester), scrolledColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);

      gesture = await tester.startGesture(const Offset(50.0, 300.0));
      await gesture.moveBy(const Offset(0.0, kToolbarHeight));
      await gesture.up();
      await tester.pumpAndSettle();

      expect(getAppBarBackgroundColor(tester), defaultColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);
    });

    testWidgets('backgroundColor animation', (WidgetTester tester) async {
      await tester.pumpWidget(
        buildAppBar(contentHeight: 1200.0, surfaceTintColor: Colors.transparent),
      );

      expect(getAppBarAnimatedBackgroundColor(tester), defaultColor);

      TestGesture gesture = await tester.startGesture(const Offset(50.0, 400.0));
      await gesture.moveBy(const Offset(0.0, -kToolbarHeight));
      await gesture.up();
      await tester.pump();

      expect(getAppBarAnimatedBackgroundColor(tester), defaultColor);
      await tester.pumpAndSettle();
      expect(getAppBarAnimatedBackgroundColor(tester), scrolledColor);

      gesture = await tester.startGesture(const Offset(50.0, 300.0));
      await gesture.moveBy(const Offset(0.0, kToolbarHeight));
      await gesture.up();
      await tester.pump();

      expect(getAppBarAnimatedBackgroundColor(tester), scrolledColor);

      // Check intermediate color values.
      await tester.pump(const Duration(milliseconds: 50));
      expect(getAppBarAnimatedBackgroundColor(tester), isSameColorAs(const Color(0xFF00C33C)));
      await tester.pump(const Duration(milliseconds: 50));
      expect(getAppBarAnimatedBackgroundColor(tester), isSameColorAs(const Color(0xFF0039C6)));

Review comment (suggestion):
`surfaceTintColor` has been deprecated in [specs](https://m3.material.io/components/top-app-bar/specs#1adcfb52-bd43-4620-aef1-ad6d60c1f7f5), even though we haven't cleaned it up here. So I think it would be better if we don't introduce more use case like this. Instead of changing `surfaceTintColor` to transparent, I think assigning `scrolledUnderElevation: 0` in appbar will also work for this test.

Code after:
    });

    testWidgets('backgroundColor', (WidgetTester tester) async {
      await tester.pumpWidget(buildAppBar(contentHeight: 1200.0));

      expect(getAppBarBackgroundColor(tester), defaultColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);

      TestGesture gesture = await tester.startGesture(const Offset(50.0, 400.0));
      await gesture.moveBy(const Offset(0.0, -kToolbarHeight));
      await gesture.up();
      await tester.pumpAndSettle();

      expect(getAppBarBackgroundColor(tester), scrolledColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);

      gesture = await tester.startGesture(const Offset(50.0, 300.0));
      await gesture.moveBy(const Offset(0.0, kToolbarHeight));
      await gesture.up();
      await tester.pumpAndSettle();

      expect(getAppBarBackgroundColor(tester), defaultColor);
      expect(tester.getSize(findAppBarMaterial()).height, kToolbarHeight);
    });

    testWidgets('backgroundColor animation', (WidgetTester tester) async {
      await tester.pumpWidget(
        buildAppBar(contentHeight: 1200.0, scrolledUnderElevation: 0, animateColor: true),
      );

      expect(getAppBarAnimatedBackgroundColor(tester), defaultColor);

      TestGesture gesture = await tester.startGesture(const Offset(50.0, 400.0));
      await gesture.moveBy(const Offset(0.0, -kToolbarHeight));
      await gesture.up();
      await tester.pump();

      expect(getAppBarAnimatedBackgroundColor(tester), defaultColor);
      await tester.pumpAndSettle();
      expect(getAppBarAnimatedBackgroundColor(tester), scrolledColor);

      gesture = await tester.startGesture(const Offset(50.0, 300.0));
      await gesture.moveBy(const Offset(0.0, kToolbarHeight));
      await gesture.up();
      await tester.pump();

      expect(getAppBarAnimatedBackgroundColor(tester), scrolledColor);

      // Check intermediate color values.
      await tester.pump(const Duration(milliseconds: 50));
      expect(getAppBarAnimatedBackgroundColor(tester), isSameColorAs(const Color(0xFF00C33C)));