mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
30 lines
728 B
Dart
30 lines
728 B
Dart
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();
|
|
}
|