/
main.dart
58 lines (53 loc) · 1.5 KB
/
main.dart
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
import 'dart:developer';
import 'package:file_picker_pro/file_data.dart';
import 'package:file_picker_pro/file_picker.dart';
import 'package:file_picker_pro/files.dart';
import 'package:flutter/material.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
FileData _fileData = FileData();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('file_picker_pro'),
),
body: SafeArea(
child: Column(
children: [
FilePicker(
context: context,
height: 100,
fileData: _fileData,
crop: true,
maxFileSizeInMb: 10,
allowedExtensions: const [
Files.txt,
Files.png,
Files.jpg,
Files.pdf
],
onSelected: (fileData) {
_fileData = fileData;
log(fileData.filePath);
setState(() {});
},
onCancel: (message, messageCode) {
log("[$messageCode] $message");
}),
],
),
),
),
);
}
}