This commit is contained in:
Flummi 2022-05-30 07:34:42 +02:00
parent dd9a61bcca
commit 40afd685dd

View File

@ -20,6 +20,13 @@ class _HomeState extends State<Home> {
f0cks = fetchDataFromApi();
}
Future loadf0cks() {
setState(() {
f0cks = fetchDataFromApi();
});
return f0cks;
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -32,8 +39,14 @@ class _HomeState extends State<Home> {
body: FutureBuilder<List<Item>>(
future: f0cks,
builder: (context, snapshot) {
if(snapshot.hasData) {
return CustomScrollView(
if(!snapshot.hasData) {
return Text("${snapshot.error}");
}
return RefreshIndicator(
onRefresh: () {
return loadf0cks();
},
child: CustomScrollView(
shrinkWrap: true,
slivers: <Widget>[
SliverGrid(
@ -83,11 +96,8 @@ class _HomeState extends State<Home> {
)
),
]
);
} else if(snapshot.hasError) {
return Text("${snapshot.error}");
}
return const CircularProgressIndicator();
)
);
}
)
);