Skip to content

Commit 82d1310

Browse files
committed
readMe created
1 parent f72830f commit 82d1310

File tree

3 files changed

+111
-25
lines changed

3 files changed

+111
-25
lines changed

README.md

Lines changed: 103 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,107 @@
1-
# file_manager
1+
# File Manager
22

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.
45

5-
## Getting Started
66

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
118

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+
[![GitHub followers](https://img.shields.io/github/followers/4-alok?style=social)](https://github.com/4-alok/)
86+
[![GitHub followers](https://img.shields.io/github/stars/4-alok/draggable_home?style=social)](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.

lib/controller/file_manager_controller.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class FileManagerController extends ChangeNotifier {
66
String _path = "";
77
SortBy _short = SortBy.size;
88

9-
/// [getSortedBy] returns the current sorting type of the List<FileSystemEntity>
9+
/// The sorting type that is currently in use is returned.
1010
SortBy get getSortedBy => _short;
1111

1212
/// [setSortedBy] is used to set the sorting type.
@@ -17,7 +17,7 @@ class FileManagerController extends ChangeNotifier {
1717
notifyListeners();
1818
}
1919

20-
/// Get current [Directory].
20+
/// Get current Directory.
2121
Directory get getCurrentDirectory => Directory(_path);
2222

2323
/// Get current path, similar to [getCurrentDirectory].

lib/file_manager.dart

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,17 @@ Future<List<Directory>?> getStorageList() async {
156156
}
157157

158158
class FileManager extends StatefulWidget {
159-
/// Provide a custom widget for loading screen.
160-
/// as default CircularProgressIndicator is provided.
159+
/// For the loading screen, create a custom widget.
160+
/// Simple Centered CircularProgressIndicator is provided by default.
161161
final Widget? loadingScreen;
162162

163-
/// Provide a custom widget for empty screen.
163+
/// For an empty screen, create a custom widget.
164164
final Widget? emptyFolder;
165165

166-
/// Provide a scroll Physics for scrolling behaviour.
167-
final ScrollPhysics? physics;
168-
169-
///shrinkwrap will only occupy the space it need
170-
final bool shrinkWrap;
171-
166+
///Controls the state of the FileManager.
172167
final FileManagerController controller;
173168

174-
///Builder is a custom builder which takes an entity and bulds a widget around it
169+
///This function allows you to create custom widgets and retrieve a list of entities `List<FileSystemEntity>.`
175170
///
176171
///
177172
///```
@@ -197,14 +192,12 @@ class FileManager extends StatefulWidget {
197192
/// ```
198193
final _Builder builder;
199194

200-
/// Hide the hidden file and folder.
195+
/// Hide the files and folders that are hidden.
201196
final bool hideHiddenEntity;
202197

203198
FileManager({
204199
this.emptyFolder,
205200
this.loadingScreen,
206-
this.physics,
207-
this.shrinkWrap = false,
208201
required this.controller,
209202
required this.builder,
210203
this.hideHiddenEntity = true,

0 commit comments

Comments
 (0)