0

I'm working on a flutter app and using ListView.builder widget to show my data. I'm fetching data from database and showing it in listview. After i modify single listitem i want to refresh whole listview widget. Currently the problem is that data which i am passing to listview widget is updating accordingly but not updating on UI. Here is the screenshot of method in which i am fetching data from database and updating listview

Image

Please help me. Thanks

nvoigt
  • 75,013
  • 26
  • 93
  • 142
Dev94
  • 757
  • 6
  • 24

1 Answers1

0

You should use a streamBuilder for fetching the data and your method for fetching the data should be as follows :

Stream<List<Map<String,dynamic>>> fetchTimeLine() async* {
 while(true) {
   //first mention how much time to wait before fetching again I am using 10 
   // secs
   await Future.delayed(Duration(seconds: 10));
   try {
      List<Map<String,dynamic>> allRows = await dbHelper.queryAllRows();
      yield allRows ; 
   } 
   finally {
      print('closed');
   }
 }
}
Amine Dakhli
  • 142
  • 8