-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.dart
More file actions
82 lines (69 loc) · 1.96 KB
/
main.dart
File metadata and controls
82 lines (69 loc) · 1.96 KB
1
2
3
4
5
6
7
8
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
import 'dart:io';
import 'package:explorer/explorer_io.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:path_provider/path_provider.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final Directory appDocDir = await getApplicationDocumentsDirectory();
runApp(MyApp(appDocDir: appDocDir));
}
class MyApp extends StatefulWidget {
const MyApp({
required this.appDocDir,
Key? key,
}) : super(key: key);
final Directory appDocDir;
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late ExplorerController _controller;
@override
void initState() {
_controller = ExplorerController(
provider: IoExplorerProvider(
entryPath: widget.appDocDir.path,
),
);
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
void filePressed(ExplorerFile file) {
if ((file.size ?? 0) > 200000) {
final snackBar =
SnackBar(content: Text('Can\'t open files with size > 200kb'));
// Find the Scaffold in the widget tree and use it to show a SnackBar.
ScaffoldMessenger.of(context).showSnackBar(snackBar);
return;
}
}
@override
Widget build(BuildContext context) => MaterialApp(
localizationsDelegates: [
ExplorerLocalizationsDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
const Locale('en', ''),
const Locale('ru', ''),
const Locale('fr', ''),
],
home: Scaffold(
body: Explorer(
controller: _controller,
builder: (_) => [
ExplorerToolbar(),
ExplorerActionView(),
ExplorerFilesGridView(),
],
filePressed: filePressed,
),
),
);
}