class DiscoverActivePageState extends State<DiscoverActivePage>
with AutomaticKeepAliveClientMixin
bool _wantKeepAlive = false;
//IM消息提醒定时器
Timer? _discoverTimer;
@override
bool get wantKeepAlive => _wantKeepAlive;
//是否保持列表状态,不自动刷新
canKeepListLive(){
//设置列表保持状态
_wantKeepAlive = true;
updateKeepAlive();
if (_discoverTimer != null) {
_discoverTimer?.cancel();
}
_discoverTimer = Timer(const Duration(minutes: 1), () {
//一分钟后又可以自动刷新列表
_wantKeepAlive = false;
updateKeepAlive();
});
}
@override
void dispose() {
if(_discoverTimer!=null){
_discoverTimer!.cancel();
}
super.dispose();
}