Коммит ffdc5f7a создал по автору iamgirya's avatar iamgirya
Просмотр файлов

Fix setState() called during build error

Line
'widget.controller.setCurrentPath = snapshot.data!.first.path'
Caused an error on open FileManager without controller.setCurrentPath
владелец 51807e96
......@@ -230,7 +230,11 @@ class _FileManagerState extends State<FileManager> {
if (widget.controller.getCurrentPath.isNotEmpty) {
currentDir = Future.value([widget.controller.getCurrentDirectory]);
} else {
currentDir = FileManager.getStorageList();
currentDir = Future(() async {
final list = await FileManager.getStorageList();
widget.controller.setCurrentPath = list.first.path;
return [widget.controller.getCurrentDirectory];
});
}
}
......@@ -254,7 +258,6 @@ class _FileManagerState extends State<FileManager> {
future: currentDir,
builder: (context, snapshot) {
if (snapshot.hasData) {
widget.controller.setCurrentPath = snapshot.data!.first.path;
return _body(context);
} else if (snapshot.hasError) {
print(snapshot.error);
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать