Открыть боковую панель
Aurora OS
Flutter
Flutter Community Plugins
file_manager
Коммиты
6922605a
Не подтверждена
Коммит
6922605a
создал
Июн 27, 2021
по автору
Arpit Sahu
Зафиксировано автором
GitHub
Июн 27, 2021
Просмотр файлов
Merge pull request #1 from Arpit-Sahu/main
added parameter in FileManager to hide Hidden Entity
владельцы
2960dbc5
24b468f0
Изменения
8
Скрыть пробелы
Построчно
Рядом
example/lib/main.dart
Просмотр файла @
6922605a
...
...
@@ -31,6 +31,11 @@ class HomePage extends StatelessWidget {
},
child:
Scaffold
(
appBar:
AppBar
(
actions:
[
IconButton
(
onPressed:
(){
// contoller.sortByName();
},
icon:
Icon
(
Icons
.
sort
),)
],
leading:
IconButton
(
icon:
Icon
(
Icons
.
arrow_back
),
onPressed:
(){},
...
...
@@ -42,6 +47,7 @@ class HomePage extends StatelessWidget {
child:
FileManager
(
controller:
controller
,
tileBuilder:
(
context
,
entity
)
{
// print(entity);
return
Card
(
child:
ListTile
(
leading:
isFile
(
entity
)
...
...
example/test/widget_test.dart
удалено
100644 → 0
Просмотр файла @
2960dbc5
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:example/main.dart'
;
void
main
()
{
testWidgets
(
'Counter increments smoke test'
,
(
WidgetTester
tester
)
async
{
// Build our app and trigger a frame.
await
tester
.
pumpWidget
(
MyApp
());
// Verify that our counter starts at 0.
expect
(
find
.
text
(
'0'
),
findsOneWidget
);
expect
(
find
.
text
(
'1'
),
findsNothing
);
// Tap the '+' icon and trigger a frame.
await
tester
.
tap
(
find
.
byIcon
(
Icons
.
add
));
await
tester
.
pump
();
// Verify that our counter has incremented.
expect
(
find
.
text
(
'0'
),
findsNothing
);
expect
(
find
.
text
(
'1'
),
findsOneWidget
);
});
}
example/web/favicon.png
удалено
100644 → 0
Просмотр файла @
2960dbc5
917 Б
example/web/icons/Icon-192.png
удалено
100644 → 0
Просмотр файла @
2960dbc5
5,2 КБ
example/web/icons/Icon-512.png
удалено
100644 → 0
Просмотр файла @
2960dbc5
8,1 КБ
example/web/index.html
удалено
100644 → 0
Просмотр файла @
2960dbc5
<!DOCTYPE html>
<html>
<head>
<!--
If you are serving your web app in a path other than the root, change the
href value below to reflect the base path you are serving from.
The path provided below has to start and end with a slash "/" in order for
it to work correctly.
For more details:
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
-->
<base
href=
"/"
>
<meta
charset=
"UTF-8"
>
<meta
content=
"IE=Edge"
http-equiv=
"X-UA-Compatible"
>
<meta
name=
"description"
content=
"A new Flutter project."
>
<!-- iOS meta tags & icons -->
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
>
<meta
name=
"apple-mobile-web-app-status-bar-style"
content=
"black"
>
<meta
name=
"apple-mobile-web-app-title"
content=
"example"
>
<link
rel=
"apple-touch-icon"
href=
"icons/Icon-192.png"
>
<title>
example
</title>
<link
rel=
"manifest"
href=
"manifest.json"
>
</head>
<body>
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
var
serviceWorkerVersion
=
null
;
var
scriptLoaded
=
false
;
function
loadMainDartJs
()
{
if
(
scriptLoaded
)
{
return
;
}
scriptLoaded
=
true
;
var
scriptTag
=
document
.
createElement
(
'
script
'
);
scriptTag
.
src
=
'
main.dart.js
'
;
scriptTag
.
type
=
'
application/javascript
'
;
document
.
body
.
append
(
scriptTag
);
}
if
(
'
serviceWorker
'
in
navigator
)
{
// Service workers are supported. Use them.
window
.
addEventListener
(
'
load
'
,
function
()
{
// Wait for registration to finish before dropping the
<
script
>
tag
.
// Otherwise, the browser will load the script multiple times,
// potentially different versions.
var
serviceWorkerUrl
=
'
flutter_service_worker.js?v=
'
+
serviceWorkerVersion
;
navigator
.
serviceWorker
.
register
(
serviceWorkerUrl
)
.
then
((
reg
)
=>
{
function
waitForActivation
(
serviceWorker
)
{
serviceWorker
.
addEventListener
(
'
statechange
'
,
()
=>
{
if
(
serviceWorker
.
state
==
'
activated
'
)
{
console
.
log
(
'
Installed new service worker.
'
);
loadMainDartJs
();
}
});
}
if
(
!
reg
.
active
&&
(
reg
.
installing
||
reg
.
waiting
))
{
// No active web worker and we have installed or are installing
// one for the first time. Simply wait for it to activate.
waitForActivation
(
reg
.
installing
??
reg
.
waiting
);
}
else
if
(
!
reg
.
active
.
scriptURL
.
endsWith
(
serviceWorkerVersion
))
{
// When the app updates the serviceWorkerVersion changes, so we
// need to ask the service worker to update.
console
.
log
(
'
New service worker available.
'
);
reg
.
update
();
waitForActivation
(
reg
.
installing
);
}
else
{
// Existing service worker is still good.
console
.
log
(
'
Loading app from service worker.
'
);
loadMainDartJs
();
}
});
// If service worker doesn't succeed in a reasonable amount of time,
// fallback to plaint
<
script
>
tag
.
setTimeout
(()
=>
{
if
(
!
scriptLoaded
)
{
console
.
warn
(
'
Failed to load app from service worker. Falling back to plain <script> tag.
'
,
);
loadMainDartJs
();
}
},
4000
);
});
}
else
{
// Service workers not supported. Just drop the
<
script
>
tag
.
loadMainDartJs
();
}
</script>
</body>
</html>
example/web/manifest.json
удалено
100644 → 0
Просмотр файла @
2960dbc5
{
"name"
:
"example"
,
"short_name"
:
"example"
,
"start_url"
:
"."
,
"display"
:
"standalone"
,
"background_color"
:
"#0175C2"
,
"theme_color"
:
"#0175C2"
,
"description"
:
"A new Flutter project."
,
"orientation"
:
"portrait-primary"
,
"prefer_related_applications"
:
false
,
"icons"
:
[
{
"src"
:
"icons/Icon-192.png"
,
"sizes"
:
"192x192"
,
"type"
:
"image/png"
},
{
"src"
:
"icons/Icon-512.png"
,
"sizes"
:
"512x512"
,
"type"
:
"image/png"
}
]
}
lib/file_manager.dart
Просмотр файла @
6922605a
...
...
@@ -4,7 +4,10 @@ import 'dart:io';
import
'package:flutter/material.dart'
;
import
'package:path_provider/path_provider.dart'
;
// enum SortBy { nameA_Z, nameZ_A, creationDateN_O, dateO_N, size }
enum
SortBy
{
name
,
date
,
}
typedef
TileBuilder
=
Widget
Function
(
BuildContext
context
,
...
...
@@ -22,7 +25,7 @@ bool isDirectory(FileSystemEntity entity) {
/// Get the basename of Directory or File by providing FileSystemEntity entity.
/// ie: controller.dirName(dir);
String
basename
(
FileSystemEntity
entity
,
[
bool
showFileExtension
=
true
])
{
return
(
!
showFileExtension
&&
(
entity
is
File
))
return
(
showFileExtension
&&
(
entity
is
File
))
?
entity
.
path
.
split
(
'/'
)
.
last
.
split
(
'.'
)
.
first
:
entity
.
path
.
split
(
'/'
)
.
last
;
}
...
...
@@ -99,12 +102,16 @@ class FileManager extends StatefulWidget {
final
FileManegerController
controller
;
final
TileBuilder
tileBuilder
;
/// Hide the hidden file and folder.
final
bool
hideHiddenEntity
;
FileManager
({
this
.
loadingScreen
,
this
.
physics
,
this
.
shrinkWrap
=
false
,
required
this
.
controller
,
required
this
.
tileBuilder
,
this
.
hideHiddenEntity
=
true
,
});
@override
...
...
@@ -151,13 +158,28 @@ class _FileManagerState extends State<FileManager> {
future:
Directory
(
pathSnapshot
)
.
list
(
recursive:
false
)
.
toList
(),
builder:
(
context
,
snapshot
)
{
if
(
snapshot
.
hasData
)
{
final
List
<
FileSystemEntity
>
entitys
=
snapshot
.
data
!
;
List
<
FileSystemEntity
>
entitys
=
snapshot
.
data
!
;
entitys
.
sort
((
a
,
b
)
=
>
a
.
path
.
toLowerCase
()
.
compareTo
(
b
.
path
.
toLowerCase
()));
if
(
widget
.
hideHiddenEntity
)
{
entitys
=
entitys
.
where
((
element
)
{
if
(
basename
(
element
)
==
""
||
basename
(
element
)
.
startsWith
(
'.'
))
{
return
false
;
}
else
{
print
(
basename
(
element
));
return
true
;
}
})
.
toList
();
}
return
ListView
.
builder
(
physics:
widget
.
physics
,
shrinkWrap:
widget
.
shrinkWrap
,
itemCount:
entitys
.
length
,
itemBuilder:
(
context
,
index
)
{
return
tileWidget
(
context
,
entitys
[
index
]);
return
widget
.
tileBuilder
(
context
,
entitys
[
index
]);
},
);
}
else
if
(
snapshot
.
hasError
)
{
...
...
@@ -170,9 +192,9 @@ class _FileManagerState extends State<FileManager> {
},
);
Widget
tileWidget
(
BuildContext
context
,
FileSystemEntity
entity
)
{
return
widget
.
tileBuilder
(
context
,
entity
);
}
//
Widget tileWidget(BuildContext context, FileSystemEntity entity) {
//
return widget.tileBuilder(context, entity);
//
}
Container
errorPage
(
String
error
)
{
return
Container
(
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать