Unverified Commit 070a5a9b authored by Suhwan Cha's avatar Suhwan Cha Committed by GitHub

Use a more appropriate curve on ScrollsToTop (#96574)

parent 610b41e8
......@@ -2583,8 +2583,8 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
if (primaryScrollController != null && primaryScrollController.hasClients) {
primaryScrollController.animateTo(
0.0,
duration: const Duration(milliseconds: 300),
curve: Curves.linear, // TODO(ianh): Use a more appropriate curve.
duration: const Duration(milliseconds: 1000),
curve: Curves.easeOutCirc,
);
}
}
......
......@@ -389,6 +389,35 @@ void main() {
expect(scrollable.position.pixels, equals(0.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Tapping the status bar scrolls to top with ease out curve animation', (WidgetTester tester) async {
const int duration = 1000;
final List<double> stops = <double>[0.842, 0.959, 0.993, 1.0];
const double scrollOffset = 1000;
await tester.pumpWidget(_buildStatusBarTestApp(debugDefaultTargetPlatformOverride));
final ScrollableState scrollable = tester.state(find.byType(Scrollable));
scrollable.position.jumpTo(scrollOffset);
await tester.tapAt(const Offset(100.0, 10.0));
await tester.pump(Duration.zero);
expect(scrollable.position.pixels, equals(scrollOffset));
for (int i = 0; i < stops.length; i++) {
await tester.pump( Duration(milliseconds: duration ~/ stops.length));
// Scroll pixel position is very long double, compare with floored int
// pixel position
expect(
scrollable.position.pixels.toInt(),
equals(
(scrollOffset * (1 - stops[i])).toInt()
)
);
}
// Finally stops at the top.
expect(scrollable.position.pixels, equals(0.0));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('Tapping the status bar does not scroll to top', (WidgetTester tester) async {
await tester.pumpWidget(_buildStatusBarTestApp(TargetPlatform.android));
final ScrollableState scrollable = tester.state(find.byType(Scrollable));
......
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