Skip to content

Commit 9ab769e

Browse files
committed
Updated ReadMe
1 parent a5fde91 commit 9ab769e

File tree

3 files changed

+89
-42
lines changed

3 files changed

+89
-42
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
![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)
66

7-
![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)
8-
97
FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more.
108
Designed to feel like part of the Flutter framework.
119

@@ -126,6 +124,7 @@ FileManager(
126124
| `isRootDirectory` | return true if current directory is the root. false, if the current directory not on root of the stogare. |
127125
| `goToParentDirectory` | Jumps to the parent directory of currently opened directory if the parent is accessible. |
128126
| `openDirectory` | Open directory by providing `Directory`. |
127+
| `titleNotifier` | ValueNotifier of the current directory's basename |
129128

130129
## Others
131130

@@ -141,9 +140,14 @@ FileManager(
141140

142141
## Show some :heart: and :star: the repo
143142

143+
![GitHub Repo stars](https://img.shields.io/github/stars/DevsOnFlutter/file_manager?style=social)
144+
![GitHub forks](https://img.shields.io/github/forks/DevsOnFlutter/file_manager?style=social)
145+
[![GitHub followers](https://img.shields.io/github/followers/4-alok?style=social)](https://github.com/4-alok/)
146+
144147
## Project Created & Maintained By
145148

146-
### [DevsOnFlutter](https://github.com/DevsOnFlutter)
149+
* ### [DevsOnFlutter](https://github.com/DevsOnFlutter)
150+
147151

148152
</hr>
149153

example/lib/main.dart

Lines changed: 63 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class HomePage extends StatelessWidget {
4242
child: Scaffold(
4343
appBar: AppBar(
4444
actions: [
45+
IconButton(
46+
onPressed: () => createFolder(context),
47+
icon: Icon(Icons.create_new_folder_outlined),
48+
),
4549
IconButton(
4650
onPressed: () => sort(context),
4751
icon: Icon(Icons.sort_rounded),
@@ -52,7 +56,7 @@ class HomePage extends StatelessWidget {
5256
)
5357
],
5458
title: ValueListenableBuilder<String>(
55-
valueListenable: controller.title,
59+
valueListenable: controller.titleNotifier,
5660
builder: (context, title, _) => Text(title),
5761
),
5862
leading: IconButton(
@@ -181,40 +185,63 @@ class HomePage extends StatelessWidget {
181185

182186
sort(BuildContext context) async {
183187
showDialog(
184-
context: context,
185-
builder: (context) => Dialog(
186-
child: Container(
187-
padding: EdgeInsets.all(10),
188-
child: Column(
189-
mainAxisSize: MainAxisSize.min,
190-
children: [
191-
ListTile(
192-
title: Text("Name"),
193-
onTap: () {
194-
controller.sortedBy = SortBy.name;
195-
Navigator.pop(context);
196-
}),
197-
ListTile(
198-
title: Text("Size"),
199-
onTap: () {
200-
controller.sortedBy = SortBy.size;
201-
Navigator.pop(context);
202-
}),
203-
ListTile(
204-
title: Text("Date"),
205-
onTap: () {
206-
controller.sortedBy = SortBy.date;
207-
Navigator.pop(context);
208-
}),
209-
ListTile(
210-
title: Text("type"),
211-
onTap: () {
212-
controller.sortedBy = SortBy.type;
213-
Navigator.pop(context);
214-
}),
215-
],
216-
),
217-
),
218-
));
188+
context: context,
189+
builder: (context) => Dialog(
190+
child: Container(
191+
padding: EdgeInsets.all(10),
192+
child: Column(
193+
mainAxisSize: MainAxisSize.min,
194+
children: [
195+
ListTile(
196+
title: Text("Name"),
197+
onTap: () {
198+
controller.sortedBy = SortBy.name;
199+
Navigator.pop(context);
200+
}),
201+
ListTile(
202+
title: Text("Size"),
203+
onTap: () {
204+
controller.sortedBy = SortBy.size;
205+
Navigator.pop(context);
206+
}),
207+
ListTile(
208+
title: Text("Date"),
209+
onTap: () {
210+
controller.sortedBy = SortBy.date;
211+
Navigator.pop(context);
212+
}),
213+
ListTile(
214+
title: Text("type"),
215+
onTap: () {
216+
controller.sortedBy = SortBy.type;
217+
Navigator.pop(context);
218+
}),
219+
],
220+
),
221+
),
222+
),
223+
);
224+
}
225+
226+
createFolder(BuildContext context) async {
227+
showDialog(
228+
context: context,
229+
builder: (context) => Dialog(
230+
child: Container(
231+
padding: EdgeInsets.all(10),
232+
child: Column(
233+
mainAxisSize: MainAxisSize.min,
234+
children: [
235+
ListTile(
236+
title: Text("Name"),
237+
onTap: () {
238+
controller.sortedBy = SortBy.name;
239+
Navigator.pop(context);
240+
}),
241+
],
242+
),
243+
),
244+
),
245+
);
219246
}
220247
}

lib/controller/file_manager_controller.dart

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,30 @@ import 'package:flutter/widgets.dart';
44

55
class FileManagerController {
66
final ValueNotifier<String> _path = ValueNotifier<String>('');
7-
final ValueNotifier<String> title = ValueNotifier<String>('');
87
final ValueNotifier<SortBy> _short = ValueNotifier<SortBy>(SortBy.name);
98

109
_updatePath(String path) {
1110
_path.value = path;
12-
title.value = path.split('/').last;
11+
titleNotifier.value = path.split('/').last;
1312
}
1413

14+
/// ValueNotifier of the current directory's basename
15+
///
16+
/// ie:
17+
/// ```dart
18+
/// ValueListenableBuilder<String>(
19+
/// valueListenable: controller.titleNotifier,
20+
/// builder: (context, title, _) {
21+
/// return Text(title);
22+
/// },
23+
/// ),
24+
/// ```
25+
final ValueNotifier<String> titleNotifier = ValueNotifier<String>('');
26+
27+
/// Get ValueNotifier of path
1528
ValueNotifier<String> get getPathNotifier => _path;
29+
30+
/// Get ValueNotifier of SortedBy
1631
ValueNotifier<SortBy> get getSortedByNotifier => _short;
1732

1833
/// The sorting type that is currently in use is returned.
@@ -57,9 +72,10 @@ class FileManagerController {
5772
}
5873
}
5974

75+
/// Dispose FileManagerController
6076
void dispose() {
6177
_path.dispose();
62-
title.dispose();
78+
titleNotifier.dispose();
6379
_short.dispose();
6480
}
6581
}

0 commit comments

Comments
 (0)