|
@@ -5,6 +5,8 @@ import 'package:photo/photo.dart';
|
5
|
5
|
import 'package:photo_manager/photo_manager.dart';
|
6
|
6
|
|
7
|
7
|
import './preview.dart';
|
|
8
|
+import 'icon_text_button.dart';
|
|
9
|
+import 'picked_example.dart';
|
8
|
10
|
|
9
|
11
|
void main() => runApp(MyApp());
|
10
|
12
|
|
|
@@ -16,7 +18,7 @@ class MyApp extends StatelessWidget {
|
16
|
18
|
child: MaterialApp(
|
17
|
19
|
title: 'Pick Image Demo',
|
18
|
20
|
theme: ThemeData(
|
19
|
|
- primarySwatch: Colors.blue,
|
|
21
|
+ primarySwatch: Colors.lime,
|
20
|
22
|
),
|
21
|
23
|
home: MyHomePage(title: 'Pick Image Demo'),
|
22
|
24
|
),
|
|
@@ -80,20 +82,24 @@ class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
|
80
|
82
|
child: Column(
|
81
|
83
|
children: <Widget>[
|
82
|
84
|
IconTextButton(
|
83
|
|
- icon: Icons.photo,
|
84
|
|
- text: "photo",
|
85
|
|
- onTap: () => _pickAsset(PickType.onlyImage)),
|
|
85
|
+ icon: Icons.photo,
|
|
86
|
+ text: "photo",
|
|
87
|
+ onTap: () => _pickAsset(PickType.onlyImage),
|
|
88
|
+ ),
|
|
89
|
+ IconTextButton(
|
|
90
|
+ icon: Icons.videocam,
|
|
91
|
+ text: "video",
|
|
92
|
+ onTap: () => _pickAsset(PickType.onlyVideo),
|
|
93
|
+ ),
|
86
|
94
|
IconTextButton(
|
87
|
|
- icon: Icons.videocam,
|
88
|
|
- text: "video",
|
89
|
|
- onTap: () => _pickAsset(PickType.onlyVideo)),
|
|
95
|
+ icon: Icons.album,
|
|
96
|
+ text: "all",
|
|
97
|
+ onTap: () => _pickAsset(PickType.all),
|
|
98
|
+ ),
|
90
|
99
|
IconTextButton(
|
91
|
|
- icon: Icons.album,
|
92
|
|
- text: "all",
|
93
|
|
- onTap: () => _pickAsset(PickType.all)),
|
94
|
|
- Text(
|
95
|
|
- '$currentSelected',
|
96
|
|
- textAlign: TextAlign.center,
|
|
100
|
+ icon: CupertinoIcons.reply_all,
|
|
101
|
+ text: "Picked asset example.",
|
|
102
|
+ onTap: () => routePage(PickedExample()),
|
97
|
103
|
),
|
98
|
104
|
],
|
99
|
105
|
),
|
|
@@ -182,25 +188,14 @@ class _MyHomePageState extends State<MyHomePage> with LoadingDelegate {
|
182
|
188
|
}
|
183
|
189
|
setState(() {});
|
184
|
190
|
}
|
185
|
|
-}
|
186
|
|
-
|
187
|
|
-class IconTextButton extends StatelessWidget {
|
188
|
|
- final IconData icon;
|
189
|
|
- final String text;
|
190
|
|
- final Function onTap;
|
191
|
191
|
|
192
|
|
- const IconTextButton({Key key, this.icon, this.text, this.onTap})
|
193
|
|
- : super(key: key);
|
194
|
|
-
|
195
|
|
- @override
|
196
|
|
- Widget build(BuildContext context) {
|
197
|
|
- return InkWell(
|
198
|
|
- onTap: onTap,
|
199
|
|
- child: Container(
|
200
|
|
- child: ListTile(
|
201
|
|
- leading: Icon(icon ?? Icons.device_unknown),
|
202
|
|
- title: Text(text ?? ""),
|
203
|
|
- ),
|
|
192
|
+ void routePage(Widget widget) {
|
|
193
|
+ Navigator.push(
|
|
194
|
+ context,
|
|
195
|
+ MaterialPageRoute(
|
|
196
|
+ builder: (BuildContext context) {
|
|
197
|
+ return widget;
|
|
198
|
+ },
|
204
|
199
|
),
|
205
|
200
|
);
|
206
|
201
|
}
|