懒加载优化性能

This commit is contained in:
jyuesong
2022-01-19 14:47:11 +08:00
parent 6185a92759
commit 16f4f27f17
2 changed files with 26 additions and 43 deletions

View File

@@ -6,6 +6,7 @@ import 'package:qinglong_app/base/http/http.dart';
import 'package:qinglong_app/base/ql_app_bar.dart';
import 'package:qinglong_app/base/routes.dart';
import 'package:qinglong_app/base/theme.dart';
import 'package:qinglong_app/base/ui/lazy_load_state.dart';
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
import 'package:qinglong_app/utils/extension.dart';
@@ -17,15 +18,9 @@ class ScriptPage extends ConsumerStatefulWidget {
_ScriptPageState createState() => _ScriptPageState();
}
class _ScriptPageState extends ConsumerState<ScriptPage> {
class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<ScriptPage> {
List<ScriptBean> list = [];
@override
void initState() {
super.initState();
loadData();
}
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -51,9 +46,8 @@ class _ScriptPageState extends ConsumerState<ScriptPage> {
title: Text(
item.title ?? "",
style: TextStyle(
color: (item.disabled ?? false)
? ref.watch(themeProvider).themeColor.descColor()
: ref.watch(themeProvider).themeColor.titleColor(),
color:
(item.disabled ?? false) ? ref.watch(themeProvider).themeColor.descColor() : ref.watch(themeProvider).themeColor.titleColor(),
fontSize: 16,
),
),
@@ -93,9 +87,8 @@ class _ScriptPageState extends ConsumerState<ScriptPage> {
title: Text(
item.title ?? "",
style: TextStyle(
color: (item.disabled ?? false)
? ref.watch(themeProvider).themeColor.descColor()
: ref.watch(themeProvider).themeColor.titleColor(),
color:
(item.disabled ?? false) ? ref.watch(themeProvider).themeColor.descColor() : ref.watch(themeProvider).themeColor.titleColor(),
fontSize: 16,
),
),
@@ -118,4 +111,9 @@ class _ScriptPageState extends ConsumerState<ScriptPage> {
response.message?.toast();
}
}
@override
void onLazyLoad() {
loadData();
}
}