refresh on pulling down

This commit is contained in:
Göran Heinemann 2020-04-02 00:10:20 +02:00
parent 29f2f296e4
commit c77e44bc96

View File

@ -18,7 +18,7 @@ class WorkoutsViewState extends State<WorkoutsView>{
Future<List> getWorkouts() async { Future<List> getWorkouts() async {
var response = await http.get( var response = await http.get(
"http://10.16.17.65/api/index.php?token=satbwertwhbertnwertwertghwertgwertg", "http://10.16.17.18/api/index.php?token=satbwertwhbertnwertwertghwertgwertg",
headers: { headers: {
"Accept": "application/json" "Accept": "application/json"
} }
@ -39,20 +39,23 @@ class WorkoutsViewState extends State<WorkoutsView>{
Widget build(BuildContext context) { Widget build(BuildContext context) {
// TODO: implement build // TODO: implement build
return Scaffold( return Scaffold(
body: ListView.builder( body: RefreshIndicator(
itemCount: data == null ? 0 : data.length, child: ListView.builder(
itemBuilder: (BuildContext context, int index){ itemCount: data == null ? 0 : data.length,
return new ListTile( itemBuilder: (BuildContext context, int index){
leading: Icon(Icons.add), return new ListTile(
title: Text(data[index]['title']), leading: Icon(Icons.add),
subtitle: Text(data[index]['creator']), title: Text(data[index]['title']),
onTap: (){ subtitle: Text(data[index]['creator']),
Navigator.push(context, MaterialPageRoute( onTap: (){
builder: (context) => ExerciseView(data[index]['title'], data[index]['id']) Navigator.push(context, MaterialPageRoute(
)); builder: (context) => ExerciseView(data[index]['title'], data[index]['id'])
}, ));
); },
}, );
},
),
onRefresh: getWorkouts,
), ),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: (){ onPressed: (){