mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add scripts
This commit is contained in:
29
lib/base/ui/lazy_load_state.dart
Normal file
29
lib/base/ui/lazy_load_state.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// @author NewTab
|
||||
|
||||
mixin LazyLoadState<T extends StatefulWidget> on State<T> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||
var route = ModalRoute.of(context);
|
||||
void handler(status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
route?.animation?.removeStatusListener(handler);
|
||||
onLazyLoad();
|
||||
}
|
||||
}
|
||||
|
||||
if (route == null ||
|
||||
route.animation == null ||
|
||||
route.animation!.status == AnimationStatus.completed) {
|
||||
onLazyLoad();
|
||||
} else {
|
||||
route.animation!.addStatusListener(handler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void onLazyLoad();
|
||||
}
|
||||
Reference in New Issue
Block a user