mod: 控制器监听事件移除

This commit is contained in:
guozhigq
2023-08-20 09:12:31 +08:00
parent 6bbbdd7710
commit 8627869309
16 changed files with 114 additions and 31 deletions

View File

@ -1,3 +1,4 @@
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pilipala/common/skeleton/video_card_h.dart';
@ -17,25 +18,33 @@ class HistoryPage extends StatefulWidget {
class _HistoryPageState extends State<HistoryPage> {
final HistoryController _historyController = Get.put(HistoryController());
Future? _futureBuilderFuture;
late ScrollController scrollController;
@override
void initState() {
_futureBuilderFuture = _historyController.queryHistoryList();
super.initState();
_historyController.scrollController.addListener(
scrollController = _historyController.scrollController;
scrollController.addListener(
() {
if (_historyController.scrollController.position.pixels >=
_historyController.scrollController.position.maxScrollExtent -
300) {
if (scrollController.position.pixels >=
scrollController.position.maxScrollExtent - 300) {
if (!_historyController.isLoadingMore.value) {
_historyController.onLoad();
EasyThrottle.throttle('history', const Duration(seconds: 1), () {
_historyController.onLoad();
});
}
}
},
);
}
@override
void dispose() {
scrollController.removeListener(() {});
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(