I wrote a function that returns a SingleChildScrollView to the top. I want to execute this function on the buttons of outside this widget, how should I implement this?
Here's my current code.
timeline.dart
import 'package:flutter/material.dart';
import 'package:social_app/functions/functions.dart';
class TimeLinePage extends StatelessWidget {
const TimeLinePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final ScrollController timeLineScrollController = ScrollController();
void timeLineJumpToTop() {
jumpToTop(timeLineScrollController);
}
...
functions.dart
import 'package:flutter/material.dart';
void jumpToTop(ScrollController scrollController) {
scrollController.animateTo(0.0,
duration: const Duration(milliseconds: 1000), curve: Curves.easeInOutQuart);
}
Thank you.