32 lines
920 B
Dart
32 lines
920 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ScrollToTopButton extends StatelessWidget {
|
|
final ScrollController scrollController;
|
|
|
|
const ScrollToTopButton({super.key, required this.scrollController});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(bottom: 8),
|
|
child: Tooltip(
|
|
message: 'Scroll to top',
|
|
preferBelow: false,
|
|
child: ElevatedButton(
|
|
onPressed: () => scrollController.animateTo(
|
|
0.0,
|
|
curve: Curves.easeOut,
|
|
duration: const Duration(milliseconds: 500),
|
|
),
|
|
style: ElevatedButton.styleFrom(
|
|
shape: const CircleBorder(),
|
|
padding: const EdgeInsets.all(16),
|
|
),
|
|
child: const Icon(Icons.arrow_upward_rounded),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|