|
1 | | -# file_manager |
| 1 | +# File Manager |
2 | 2 |
|
3 | | -A new Flutter project. |
| 3 | +File manager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. |
| 4 | +Designed to feel like part of the Flutter framework. |
4 | 5 |
|
5 | | -## Getting Started |
6 | 6 |
|
7 | | -This project is a starting point for a Dart |
8 | | -[package](https://flutter.dev/developing-packages/), |
9 | | -a library module containing code that can be shared easily across |
10 | | -multiple Flutter or Dart projects. |
| 7 | +## Usage |
11 | 8 |
|
12 | | -For help getting started with Flutter, view our |
13 | | -[online documentation](https://flutter.dev/docs), which offers tutorials, |
14 | | -samples, guidance on mobile development, and a full API reference. |
| 9 | +Make sure to check out [examples](https://github.com/DevsOnFlutter/file_manager/blob/main/example/lib/main.dart) for more details. |
| 10 | + |
| 11 | +### Installation |
| 12 | + |
| 13 | +Add the following line to `pubspec.yaml`: |
| 14 | + |
| 15 | +```yaml |
| 16 | +dependencies: |
| 17 | + file_manager: ^1.0.0 |
| 18 | +``` |
| 19 | +
|
| 20 | +### Basic setup |
| 21 | +
|
| 22 | +*The complete example is available [here](https://github.com/4-alok/draggable_home/blob/main/example/lib/main.dart).* |
| 23 | +
|
| 24 | +Required parameter for **FileManager** are `controller` and `builder` |
| 25 | +* `controller` The controller updates value and notifies its listeners, and FileManager updates itself appropriately whenever the user modifies the path or changes the sort-type with an associated FileManagerController. |
| 26 | +``` |
| 27 | +final FileManagerController controller = FileManagerController(); |
| 28 | +``` |
| 29 | +* `builder` This function allows you to create custom widgets and retrieve a list of entities `List<FileSystemEntity>.` |
| 30 | +
|
| 31 | +
|
| 32 | +
|
| 33 | +Sample code |
| 34 | +```dart |
| 35 | +FileManager( |
| 36 | + controller: controller, |
| 37 | + builder: (context, snapshot) { |
| 38 | + final List<FileSystemEntity> entitis = snapshot; |
| 39 | + return ListView.builder( |
| 40 | + itemCount: entitis.length, |
| 41 | + itemBuilder: (context, index) { |
| 42 | + return Card( |
| 43 | + child: ListTile( |
| 44 | + leading: isFile(entitis[index]) |
| 45 | + ? Icon(Icons.feed_outlined) |
| 46 | + : Icon(Icons.folder), |
| 47 | + title: Text(basename(entitis[index])), |
| 48 | + onTap: () { |
| 49 | + if (isDirectory(entitis[index])) { |
| 50 | + controller.openDirectory(entitis[index]); // open directory |
| 51 | + } else { |
| 52 | + // Perform file-related tasks. |
| 53 | + } |
| 54 | + }, |
| 55 | + ), |
| 56 | + ); |
| 57 | + }, |
| 58 | + ); |
| 59 | + }, |
| 60 | +), |
| 61 | +``` |
| 62 | + |
| 63 | +## FileManager |
| 64 | +| Properties | Description | |
| 65 | +|--------------|-----------------| |
| 66 | +| `loadingScreen` | For the loading screen, create a custom widget. A simple Centered CircularProgressIndicator is provided by default. | |
| 67 | +| `emptyFolder` | For an empty screen, create a custom widget. | |
| 68 | +| `controller` | For an empty screen, create a custom widget. | |
| 69 | +| `hideHiddenEntity` | Hide the files and folders that are hidden. | |
| 70 | +| `builder` | This function allows you to create custom widgets and retrieve a list of entities `List<FileSystemEntity>.` | |
| 71 | + |
| 72 | +## FileManagerContoller |
| 73 | +| Properties | Description | |
| 74 | +|--------------|-----------------| |
| 75 | +| `getSortedBy` | The sorting type that is currently in use is returned. | |
| 76 | +| `setSortedBy` | is used to set the sorting type. `SortBy{ name, type, date, size }`. | |
| 77 | +| `getCurrentDirectory` | Get current Directory | |
| 78 | +| `getCurrentPath` | Get current path, similar to [getCurrentDirectory]. | |
| 79 | +| `setCurrentPath` | Set current directory path by providing `String` of path, similar to [openDirectory]. `List<FileSystemEntity>.` | |
| 80 | +| `goToParentDirectory` | `goToParentDirectory` returns `bool`, goes to the parent directory of currently opened directory if the parent is accessible, return true if current directory is the root. false, if the current directory not on root of the stogare.. | |
| 81 | +| `openDirectory` | Open directory by providing `Directory`. | |
| 82 | + |
| 83 | +## Show some :heart: and :star: the repo |
| 84 | + |
| 85 | +[](https://github.com/4-alok/) |
| 86 | +[](https://github.com/4-alok/) |
| 87 | + |
| 88 | +## Contributions |
| 89 | + |
| 90 | +Contributions are welcomed! |
| 91 | + |
| 92 | +If you feel that a hook is missing, feel free to open a pull-request. |
| 93 | + |
| 94 | +For a custom-hook to be merged, you will need to do the following: |
| 95 | + |
| 96 | +- Describe the use-case. |
| 97 | + |
| 98 | +- Open an issue explaining why we need this hook, how to use it, ... |
| 99 | + This is important as a hook will not get merged if the hook doens't appeal to |
| 100 | + a large number of people. |
| 101 | + |
| 102 | +- If your hook is rejected, don't worry! A rejection doesn't mean that it won't |
| 103 | + be merged later in the future if more people shows an interest in it. |
| 104 | + In the mean-time, feel free to publish your hook as a package on https://pub.dev. |
| 105 | + |
| 106 | +- A hook will not be merged unles fully tested, to avoid breaking it inadvertendly |
| 107 | + in the future. |
0 commit comments