mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
search settings
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/res.dart';
|
||||
|
||||
abstract class LoadingState<T extends StatefulWidget, S extends Object> extends State<T>{
|
||||
bool isLoading = true;
|
||||
bool isLoading = false;
|
||||
|
||||
S? data;
|
||||
|
||||
@@ -13,22 +13,29 @@ abstract class LoadingState<T extends StatefulWidget, S extends Object> extends
|
||||
|
||||
Widget buildContent(BuildContext context, S data);
|
||||
|
||||
@override
|
||||
@mustCallSuper
|
||||
void initState() {
|
||||
isLoading = true;
|
||||
loadData().then((value) {
|
||||
if(value.success) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
data = value.data;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
error = value.errorMessage!;
|
||||
});
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if(isLoading){
|
||||
loadData().then((value) {
|
||||
if(value.success) {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
data = value.data;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
error = value.errorMessage!;
|
||||
});
|
||||
}
|
||||
});
|
||||
return const Center(
|
||||
child: ProgressRing(),
|
||||
);
|
||||
|
Reference in New Issue
Block a user