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?