Add haptics to scroll to top button

This commit is contained in:
tommyxchow 2022-01-07 19:38:10 -05:00
parent 3ab5bab035
commit 6a1f7788e6

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class ScrollToTopButton extends StatelessWidget {
final ScrollController scrollController;
@ -9,11 +10,14 @@ class ScrollToTopButton extends StatelessWidget {
Widget build(BuildContext context) {
return ElevatedButton.icon(
label: const Text('Scroll to Top'),
onPressed: () => scrollController.animateTo(
0.0,
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 500),
),
onPressed: () {
HapticFeedback.lightImpact();
scrollController.animateTo(
0.0,
curve: Curves.fastOutSlowIn,
duration: const Duration(milliseconds: 500),
);
},
icon: const Icon(
Icons.arrow_circle_up,
),