README.md 4,9 КБ
Newer Older
4-alok's avatar
4-alok включено в состав коммита
1
# File Manager
4-alok's avatar
4-alok включено в состав коммита
2

4-alok's avatar
4-alok включено в состав коммита
3
FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more.
4-alok's avatar
4-alok включено в состав коммита
4
Designed to feel like part of the Flutter framework.
4-alok's avatar
4-alok включено в состав коммита
5
6


4-alok's avatar
4-alok включено в состав коммита
7
## Usage
4-alok's avatar
4-alok включено в состав коммита
8

4-alok's avatar
4-alok включено в состав коммита
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Make sure to check out [examples](https://github.com/DevsOnFlutter/file_manager/blob/main/example/lib/main.dart) for more details.

### Installation

Add the following line to `pubspec.yaml`:

```yaml
dependencies:
  file_manager: ^1.0.0
```

### Basic setup

*The complete example is available [here](https://github.com/4-alok/draggable_home/blob/main/example/lib/main.dart).*

Required parameter for **FileManager** are `controller` and `builder`
* `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.
```
final FileManagerController controller = FileManagerController();
```
* `builder` This function allows you to create custom widgets and retrieve a list of entities `List<FileSystemEntity>.`



Sample code
```dart
FileManager(
    controller: controller,
    builder: (context, snapshot) {
    final List<FileSystemEntity> entitis = snapshot;
      return ListView.builder(
        itemCount: entitis.length,
        itemBuilder: (context, index) {
          return Card(
            child: ListTile(
              leading: isFile(entitis[index])
                  ? Icon(Icons.feed_outlined)
                  : Icon(Icons.folder),
              title: Text(basename(entitis[index])),
              onTap: () {
                if (isDirectory(entitis[index])) {
                    controller.openDirectory(entitis[index]);   // open directory
                  } else {
                      // Perform file-related tasks.
                  }
              },
            ),
          );
        },
      );
  },
),
```

## FileManager
|  Properties  |   Description   |
|--------------|-----------------|
| `loadingScreen` | For the loading screen, create a custom widget. A simple Centered CircularProgressIndicator is provided by default. |
| `emptyFolder` | For an empty screen, create a custom widget. |
| `controller` | For an empty screen, create a custom widget. |
| `hideHiddenEntity` | Hide the files and folders that are hidden. |
| `builder` | This function allows you to create custom widgets and retrieve a list of entities `List<FileSystemEntity>.` |

## FileManagerContoller
|  Properties  |   Description   |
|--------------|-----------------|
| `getSortedBy` | The sorting type that is currently in use is returned. |
| `setSortedBy` | is used to set the sorting type. `SortBy{ name, type, date, size }`. |
| `getCurrentDirectory` | Get current Directory |
| `getCurrentPath` | Get current path, similar to [getCurrentDirectory]. |
| `setCurrentPath` | Set current directory path by providing `String` of path, similar to [openDirectory]. `List<FileSystemEntity>.` |
| `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.. |
| `openDirectory` | Open directory by providing `Directory`. |

4-alok's avatar
4-alok включено в состав коммита
83
84
85
86
87
88
89
90
91
92
93
94
95
96
## Otheres
|  Properties  |   Description   |
|--------------|-----------------|
| `isFile` | check weather FileSystemEntity is File. |
| `isDirectory` | check weather FileSystemEntity is Directory. |
| `basename` | Get the basename of Directory or File. Provide `File`, `Directory` or `FileSystemEntity` and returns the name as a `String`. ie
```dart
 controller.dirName(dir);
```
|
| `formatBytes` | Convert bytes to human readable size.[getCurrentDirectory]. |
| `setCurrentPath` | Set current directory path by providing `String` of path, similar to [openDirectory]. `List<FileSystemEntity>.` |
| `getStorageList` | Get list of available storage in the device, returns an empty list if there is no storage `List<Directory>`|

4-alok's avatar
4-alok включено в состав коммита
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
## Show some :heart: and :star: the repo

[![GitHub followers](https://img.shields.io/github/followers/4-alok?style=social)](https://github.com/4-alok/)
[![GitHub followers](https://img.shields.io/github/stars/4-alok/draggable_home?style=social)](https://github.com/4-alok/)

## Contributions

Contributions are welcomed!

If you feel that a hook is missing, feel free to open a pull-request.

For a custom-hook to be merged, you will need to do the following:

- Describe the use-case.

-  Open an issue explaining why we need this hook, how to use it, ...
  This is important as a hook will not get merged if the hook doens't appeal to
  a large number of people.

-  If your hook is rejected, don't worry! A rejection doesn't mean that it won't
  be merged later in the future if more people shows an interest in it.
  In the mean-time, feel free to publish your hook as a package on https://pub.dev.

-  A hook will not be merged unles fully tested, to avoid breaking it inadvertendly
  in the future.