Add haptics to scroll to top button
This commit is contained in:
parent
3ab5bab035
commit
6a1f7788e6
1 changed files with 9 additions and 5 deletions
|
|
@ -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,
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue