diff --git a/lib/view/home.dart b/lib/view/home.dart index 714796e..311a49e 100644 --- a/lib/view/home.dart +++ b/lib/view/home.dart @@ -20,6 +20,13 @@ class _HomeState extends State { f0cks = fetchDataFromApi(); } + Future loadf0cks() { + setState(() { + f0cks = fetchDataFromApi(); + }); + return f0cks; + } + @override Widget build(BuildContext context) { return Scaffold( @@ -32,8 +39,14 @@ class _HomeState extends State { body: FutureBuilder>( 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: [ SliverGrid( @@ -83,11 +96,8 @@ class _HomeState extends State { ) ), ] - ); - } else if(snapshot.hasError) { - return Text("${snapshot.error}"); - } - return const CircularProgressIndicator(); + ) + ); } ) );