Quantcast
Channel: Active questions tagged listview - Stack Overflow
Viewing all articles
Browse latest Browse all 790

Flutter listview refresh bug after renaming a bunch of files

$
0
0

I have a listview:

 ListView.builder(                    itemCount: files.length,                    itemBuilder: (BuildContext context, int index) {                      return Padding(                        padding: const EdgeInsets.symmetric(horizontal: 8.0),                        child: Text(files[index].path.split(separator).last),                      );                    },                  ),

I run a renamer, and setState the list after renaming. But the ListView is incomplete. Both old and new filenames.

        onPressed: () {          if (dir != null) {            for (var file in files) {              String oldName = p.basename(file.path);              print(oldName);              String path = p.dirname(file.path);              String addString = excelList![oldName.split('_')[0]] ?? excelList![oldName.split('')[0]] ?? '';              if(addString != '') {                              String newName = '${addString}_$oldName';              file.rename('$path/$newName');              }            }            setState(() {              List<FileSystemEntity> entities = dir!.listSync();              files = entities.whereType<File>().toList();            });          }

I need an await somewhere? I do not want to await each file.rename command. I want to await the whole for(){rename} process.Any better solution? How can I check the whole rename process finished?


Viewing all articles
Browse latest Browse all 790

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>