frosty/lib/widgets/scroll_to_top_button.dart
Tommy Chow 5c3b0c6775 Tweak animation curves (#90)
Changed button and scale curves to
improve responsiveness (makes the button react
faster when tapping).
2022-06-28 21:32:27 -04:00

30 lines
787 B
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class ScrollToTopButton extends StatelessWidget {
final ScrollController scrollController;
const ScrollToTopButton({Key? key, required this.scrollController}) : super(key: key);
@override
Widget build(BuildContext context) {
return Tooltip(
message: 'Scroll to Top',
preferBelow: false,
child: FloatingActionButton(
onPressed: () {
HapticFeedback.lightImpact();
scrollController.animateTo(
0.0,
curve: Curves.easeOutCubic,
duration: const Duration(milliseconds: 500),
);
},
mini: true,
heroTag: null,
child: const Icon(Icons.keyboard_arrow_up),
),
);
}
}