Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/flutter/lib/src/material/page_transitions_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,11 @@ class _ZoomEnterTransition extends StatelessWidget {
},
child: FadeTransition(
opacity: fadeTransition,
child: ScaleTransition(scale: scaleTransition, child: child),
child: ScaleTransition(
scale: scaleTransition,
filterQuality: FilterQuality.none,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without knowing the background this seems strange. Should we add comments? Or is the idea that the docs on ScaleTransition cover this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What seems strange?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing a filter quality to the scale transition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its documented on those widgets that it uses an ImageFilter if one is provided, though the documentation isn't extensive: https://api.flutter.dev/flutter/widgets/ScaleTransition/filterQuality.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have chosen FilterQuality.low. I don't think there will be much performance difference, but low will be smoother.

child: child,
),
),
);
}
Expand Down Expand Up @@ -372,7 +376,11 @@ class _ZoomExitTransition extends StatelessWidget {

return FadeTransition(
opacity: fadeTransition,
child: ScaleTransition(scale: scaleTransition, child: child),
child: ScaleTransition(
scale: scaleTransition,
filterQuality: FilterQuality.none,
child: child,
),
);
}
}
Expand Down
58 changes: 58 additions & 0 deletions packages/flutter/test/material/page_transitions_theme_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
Expand Down Expand Up @@ -220,4 +221,61 @@ void main() {
await tester.pumpAndSettle();
expect(builtCount, 1);
}, variant: TargetPlatformVariant.only(TargetPlatform.android));

testWidgets('_ZoomPageTransition uses a FilterQuality while animating', (WidgetTester tester) async {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => Material(
child: TextButton(
child: const Text('push'),
onPressed: () { Navigator.of(context).pushNamed('/b'); },
),
),
'/b': (BuildContext context) => StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return TextButton(
child: const Text('pop'),
onPressed: () { Navigator.pop(context); },
);
},
),
};

await tester.pumpWidget(
MaterialApp(
theme: ThemeData(
pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: ZoomPageTransitionsBuilder(), // creates a _ZoomPageTransition
},
),
),
routes: routes,
),
);

expect(tester.layers, isNot(contains(isA<ImageFilterLayer>())));

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

expect(tester.layers, contains(isA<ImageFilterLayer>()));
expect(tester.layers.whereType<ImageFilterLayer>(), hasLength(1));

await tester.pumpAndSettle();

expect(tester.layers, isNot(contains(isA<ImageFilterLayer>())));

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

expect(tester.layers, contains(isA<ImageFilterLayer>()));
// exiting requires two different zooms.
expect(tester.layers.whereType<ImageFilterLayer>(), hasLength(2));

await tester.pumpAndSettle();

expect(tester.layers, isNot(contains(isA<ImageFilterLayer>())));
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
}