1-) FLUTTER - SingleChildScrollView un scroll unu en yukarı veya en aşağı kaydırma curve easeInOut easeOut
1-) ilk olarak gerekli tanımlamaları yaparız
late ScrollController scrollController;
@override
void initState() {
// TODO: implement initState
super.initState();
scrollController = new ScrollController();
}
2 -) tanımladığımızı controller a set ederiz
child: SingleChildScrollView(
controller: scrollController,
...
)
3-) toTop() metodu scrollu en üste kaydırır
void toTop() {
scrollController.animateTo(0,
duration: Duration(milliseconds: 500), curve: Curves.easeInOut);
}
4-) Kullanımı
ElevatedButton(
onPressed: () {
toTop();
}}
5-) toBottom() metodu scrollu en aşağı kaydırır
void toBottom() {
scrollController.animateTo(
scrollController.position.maxScrollExtent,
curve: Curves.easeOut,
duration: const Duration(milliseconds: 500),);
}
6-) toDownLittle() metodu scrollu belirli pixel de aşağı indirir
kaynak : https://stackoverflow.com/questions/49153087/flutter-scrolling-to-a-widget-in-listview
void toDownLittle(int index,double _height) { scrollController.animateTo( index * _height, duration: Duration(seconds: 2), curve: Curves.fastOutSlowIn, ); } | KULLANIMI setState(() { toDownLittle(index,500); }); açıklama : index -> ListView daki itemin indexi |
************* EĞER STATE DEĞİŞKENSE TİMER KOYUP VERİ GELİNCE EL ALTA İNER *************
void toBottom() {
final periodicTimer = Timer.periodic(
const Duration(seconds: 1),
(timer) {
EasyLoading.showToast("calisti ");
if (seciliRestoranModel != null) {
scrollController.animateTo(
scrollController.position.maxScrollExtent,
curve: Curves.easeOut,
duration: const Duration(milliseconds: 500),
);
timer.cancel();
}
},
);
}