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

Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
3
4
5
6
7
8
<img src="https://i.imgur.com/NNaUK60.png"></img>

![GitHub](https://img.shields.io/github/license/DevsOnFlutter/file_manager?style=plastic) ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/DevsOnFlutter/file_manager?style=plastic) ![GitHub top language](https://img.shields.io/github/languages/top/DevsOnFlutter/file_manager?style=plastic) ![GitHub language count](https://img.shields.io/github/languages/count/DevsOnFlutter/file_manager?style=plastic) ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/DevsOnFlutter/file_manager?style=plastic) ![GitHub issues](https://img.shields.io/github/issues/DevsOnFlutter/file_manager?style=plastic) 

![GitHub Repo stars](https://img.shields.io/github/stars/DevsOnFlutter/file_manager?style=social) ![GitHub forks](https://img.shields.io/github/forks/DevsOnFlutter/file_manager?style=social)

4-alok's avatar
4-alok включено в состав коммита
9
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 включено в состав коммита
10
Designed to feel like part of the Flutter framework.
4-alok's avatar
4-alok включено в состав коммита
11

Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
12
13
14
15
16
17
##  Compatibility

&nbsp; Android </br>
&nbsp; Windows </br>
&nbsp; Linux </br>
&nbsp; iOS (active issue: [iOS support](https://github.com/DevsOnFlutter/file_manager/issues/7))
4-alok's avatar
4-alok включено в состав коммита
18

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

4-alok's avatar
4-alok включено в состав коммита
21
22
23
24
Make sure to check out [examples](https://github.com/DevsOnFlutter/file_manager/blob/main/example/lib/main.dart) for more details.

### Installation

4-alok's avatar
4-alok включено в состав коммита
25
26
Give storage permission to application

Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
27
Beside needing to add **WRITE_EXTERNAL_STORAGE** and **READ_EXTERNAL_STORAGE** to your android/app/src/main/AndroidManifest.xml.
4-alok's avatar
4-alok включено в состав коммита
28
29
30
31
32
33
34
35
36
37
38
39
40

```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxx.yyy">
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

    <application
      android:requestLegacyExternalStorage="true"   
      ...
...
</manifest>
```
Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
41
also add for Android 10
4-alok's avatar
4-alok включено в состав коммита
42
43
44
45
46
47
48
49
50
```
    <application
      android:requestLegacyExternalStorage="true"   
      ...
```

**You also need Runtime Request Permission**
allow storage permission from app setting manually or you may use any package such as [`permission_handler`](https://pub.dev/packages/permission_handler).

4-alok's avatar
4-alok включено в состав коммита
51
52
53
54
55
56
57
58
59
Add the following line to `pubspec.yaml`:

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

### Basic setup

Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
60
*The complete example is available [here](https://github.com/DevsOnFlutter/file_manager/blob/main/example/lib/main.dart).*
4-alok's avatar
4-alok включено в состав коммита
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

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) {
Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
76
    final List<FileSystemEntity> entities = snapshot;
4-alok's avatar
4-alok включено в состав коммита
77
      return ListView.builder(
Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
78
        itemCount: entities.length,
4-alok's avatar
4-alok включено в состав коммита
79
80
81
        itemBuilder: (context, index) {
          return Card(
            child: ListTile(
Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
82
              leading: isFile(entities[index])
4-alok's avatar
4-alok включено в состав коммита
83
84
                  ? Icon(Icons.feed_outlined)
                  : Icon(Icons.folder),
Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
85
              title: Text(basename(entities[index])),
4-alok's avatar
4-alok включено в состав коммита
86
              onTap: () {
Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
87
88
                if (isDirectory(entities[index])) {
                    controller.openDirectory(entities[index]);   // open directory
4-alok's avatar
4-alok включено в состав коммита
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
                  } 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`. |

Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
121
## Others
4-alok's avatar
4-alok включено в состав коммита
122
123
124
125
|  Properties  |   Description   |
|--------------|-----------------|
| `isFile` | check weather FileSystemEntity is File. |
| `isDirectory` | check weather FileSystemEntity is Directory. |
4-alok's avatar
4-alok включено в состав коммита
126
| `basename` | Get the basename of Directory or File. Provide `File`, `Directory` or `FileSystemEntity` and returns the name as a `String`. If you want to hide the extension of a file, you may use optional parameter `showFileExtension`. ie ```controller.dirName(dir, true)```
4-alok's avatar
4-alok включено в состав коммита
127
128
129
130
131
|
| `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 включено в состав коммита
132
133
## Show some :heart: and :star: the repo

Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
134
135
136
137
## Project Created & Maintained By

### Alok Kumar

4-alok's avatar
4-alok включено в состав коммита
138
[![GitHub followers](https://img.shields.io/github/followers/4-alok?style=social)](https://github.com/4-alok/)
Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
139
140
141
142

### Arpit Sahu

[![GitHub followers](https://img.shields.io/github/followers/Arpit-Sahu?style=social)](https://github.com/Arpit-Sahu/)
4-alok's avatar
4-alok включено в состав коммита
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162

## 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
Divyanshu Shekhar's avatar
Divyanshu Shekhar включено в состав коммита
163
  in the future.