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