Skip to content

Commit

Permalink
Merge pull request #19 from johnny77221/main
Browse files Browse the repository at this point in the history
Reads controller's path for initial dir
  • Loading branch information
divshekhar committed Oct 8, 2022
2 parents 3500f93 + 1b9ec3d commit c1bf7f0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/file_manager.dart
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class FileManager extends StatefulWidget {
}

/// Return file extension as String.
///
///
/// ie:- `File("/../image.png")` to `"png"`
static String getFileExtension(FileSystemEntity file) {
if (file is File) {
Expand Down Expand Up @@ -271,16 +271,28 @@ class FileManager extends StatefulWidget {
}

class _FileManagerState extends State<FileManager> {
Future<List<Directory>?>? currentDir;

@override
void dispose() {
widget.controller.dispose();
super.dispose();
}

@override
void initState() {
super.initState();
if (widget.controller.getCurrentPath.isNotEmpty) {
currentDir = Future.value([widget.controller.getCurrentDirectory]);
} else {
currentDir = FileManager.getStorageList();
}
}

@override
Widget build(BuildContext context) {
return FutureBuilder<List<Directory>?>(
future: FileManager.getStorageList(),
future: currentDir,
builder: (context, snapshot) {
if (snapshot.hasData) {
widget.controller.setCurrentPath = snapshot.data!.first.path;
Expand Down

0 comments on commit c1bf7f0

Please sign in to comment.