/
main.dart
93 lines (88 loc) · 2.66 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import 'dart:io';
import 'package:camera_roll_uploader/camera_roll_uploader.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Builder(
builder: (BuildContext context) => Scaffold(
appBar: AppBar(
title: Text("Embedded Camera Roll Picker"),
),
body: CameraRollUploader(
isDownloadingImage: (downloading) {
print("downloading $downloading");
},
selectedImageCallback: (imagePath) {
print("imagePath $imagePath");
// you can create an Image with this local path
// Image.file(
// File(imagePath!),
// fit: BoxFit.cover,
// )
},
),
floatingActionButton: Column(
mainAxisSize: MainAxisSize.min,
children: [
(Platform.isIOS)
? Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: SizedBox(
width: 80,
height: 80,
child: FloatingActionButton(
heroTag: "modal",
child: Text(
"SHOW\nMODAL",
textAlign: TextAlign.center,
),
onPressed: () => _openPicker(context),
),
),
)
: Container(
width: 0.0,
height: 0.0,
),
SizedBox(
width: 80,
height: 80,
child: FloatingActionButton(
heroTag: "push",
backgroundColor: Colors.black,
child: Text(
"SHOW\nPUSH",
textAlign: TextAlign.center,
),
onPressed: () => _openPicker(context, isModal: false),
),
)
],
),
),
),
);
}
void _openPicker(BuildContext context, {bool isModal = true}) {
Navigator.of(context).push(
MaterialPageRoute(
fullscreenDialog: isModal,
builder: (BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: CameraRollUploader(),
);
},
),
);
}
}