Browse Source

add pickCamera

lucky1213 4 years ago
parent
commit
4bc1e4f19e
3 changed files with 55 additions and 50 deletions
  1. 19
    1
      lib/photo.dart
  2. 35
    49
      pubspec.lock
  3. 1
    0
      pubspec.yaml

+ 19
- 1
lib/photo.dart View File

1
 library photo;
1
 library photo;
2
 
2
 
3
 import 'dart:async';
3
 import 'dart:async';
4
+import 'dart:io';
4
 
5
 
5
 import 'package:flutter/material.dart';
6
 import 'package:flutter/material.dart';
7
+import 'package:image_picker/image_picker.dart';
6
 import 'package:photo/src/entity/_theme.dart';
8
 import 'package:photo/src/entity/_theme.dart';
7
 import 'package:photo/src/ui/page/photo_list_page.dart';
9
 import 'package:photo/src/ui/page/photo_list_page.dart';
8
 import 'package:photo/src/ui/page/photo_main_page.dart';
10
 import 'package:photo/src/ui/page/photo_main_page.dart';
116
     );
118
     );
117
   }
119
   }
118
 
120
 
121
+  static Future<File> pickCamera({
122
+    double maxWidth,
123
+    double maxHeight,
124
+    int imageQuality,
125
+    CameraDevice preferredCameraDevice,
126
+  }) async {
127
+    return ImagePicker.pickImage(
128
+      source: ImageSource.camera,
129
+      maxWidth: maxWidth,
130
+      maxHeight: maxHeight,
131
+      imageQuality: imageQuality,
132
+      preferredCameraDevice: preferredCameraDevice,
133
+    );
134
+  }
135
+
119
   Future<PickedEntity> _pickAsset(
136
   Future<PickedEntity> _pickAsset(
120
     BuildContext context,
137
     BuildContext context,
121
     Options options,
138
     Options options,
184
     );
201
     );
185
   }
202
   }
186
 
203
 
187
-  Future<void> requestPermission(BuildContext context, {@required I18nProvider provider}) async {
204
+  Future<void> requestPermission(BuildContext context,
205
+      {@required I18nProvider provider}) async {
188
     var requestPermission = await PhotoManager.requestPermission();
206
     var requestPermission = await PhotoManager.requestPermission();
189
     if (requestPermission != true) {
207
     if (requestPermission != true) {
190
       var result = await showDialog(
208
       var result = await showDialog(

+ 35
- 49
pubspec.lock View File

1
 # Generated by pub
1
 # Generated by pub
2
 # See https://dart.dev/tools/pub/glossary#lockfile
2
 # See https://dart.dev/tools/pub/glossary#lockfile
3
 packages:
3
 packages:
4
-  archive:
5
-    dependency: transitive
6
-    description:
7
-      name: archive
8
-      url: "https://pub.flutter-io.cn"
9
-    source: hosted
10
-    version: "2.0.13"
11
-  args:
12
-    dependency: transitive
13
-    description:
14
-      name: args
15
-      url: "https://pub.flutter-io.cn"
16
-    source: hosted
17
-    version: "1.6.0"
18
   async:
4
   async:
19
     dependency: transitive
5
     dependency: transitive
20
     description:
6
     description:
36
       url: "https://pub.flutter-io.cn"
22
       url: "https://pub.flutter-io.cn"
37
     source: hosted
23
     source: hosted
38
     version: "1.1.3"
24
     version: "1.1.3"
39
-  collection:
25
+  clock:
40
     dependency: transitive
26
     dependency: transitive
41
     description:
27
     description:
42
-      name: collection
28
+      name: clock
43
       url: "https://pub.flutter-io.cn"
29
       url: "https://pub.flutter-io.cn"
44
     source: hosted
30
     source: hosted
45
-    version: "1.14.12"
46
-  convert:
31
+    version: "1.0.1"
32
+  collection:
47
     dependency: transitive
33
     dependency: transitive
48
     description:
34
     description:
49
-      name: convert
35
+      name: collection
50
       url: "https://pub.flutter-io.cn"
36
       url: "https://pub.flutter-io.cn"
51
     source: hosted
37
     source: hosted
52
-    version: "2.1.1"
53
-  crypto:
38
+    version: "1.14.12"
39
+  fake_async:
54
     dependency: transitive
40
     dependency: transitive
55
     description:
41
     description:
56
-      name: crypto
42
+      name: fake_async
57
       url: "https://pub.flutter-io.cn"
43
       url: "https://pub.flutter-io.cn"
58
     source: hosted
44
     source: hosted
59
-    version: "2.1.4"
45
+    version: "1.1.0"
60
   flutter:
46
   flutter:
61
     dependency: "direct main"
47
     dependency: "direct main"
62
     description: flutter
48
     description: flutter
63
     source: sdk
49
     source: sdk
64
     version: "0.0.0"
50
     version: "0.0.0"
51
+  flutter_plugin_android_lifecycle:
52
+    dependency: transitive
53
+    description:
54
+      name: flutter_plugin_android_lifecycle
55
+      url: "https://pub.flutter-io.cn"
56
+    source: hosted
57
+    version: "1.0.7"
65
   flutter_test:
58
   flutter_test:
66
     dependency: "direct dev"
59
     dependency: "direct dev"
67
     description: flutter
60
     description: flutter
68
     source: sdk
61
     source: sdk
69
     version: "0.0.0"
62
     version: "0.0.0"
70
-  image:
63
+  image_picker:
64
+    dependency: "direct main"
65
+    description:
66
+      name: image_picker
67
+      url: "https://pub.flutter-io.cn"
68
+    source: hosted
69
+    version: "0.6.6+1"
70
+  image_picker_platform_interface:
71
     dependency: transitive
71
     dependency: transitive
72
     description:
72
     description:
73
-      name: image
73
+      name: image_picker_platform_interface
74
       url: "https://pub.flutter-io.cn"
74
       url: "https://pub.flutter-io.cn"
75
     source: hosted
75
     source: hosted
76
-    version: "2.1.12"
76
+    version: "1.0.0"
77
   matcher:
77
   matcher:
78
     dependency: transitive
78
     dependency: transitive
79
     description:
79
     description:
101
       name: path
101
       name: path
102
       url: "https://pub.flutter-io.cn"
102
       url: "https://pub.flutter-io.cn"
103
     source: hosted
103
     source: hosted
104
-    version: "1.6.4"
105
-  petitparser:
106
-    dependency: transitive
107
-    description:
108
-      name: petitparser
109
-      url: "https://pub.flutter-io.cn"
110
-    source: hosted
111
-    version: "2.4.0"
104
+    version: "1.7.0"
112
   photo_manager:
105
   photo_manager:
113
     dependency: "direct main"
106
     dependency: "direct main"
114
     description:
107
     description:
116
       url: "https://pub.flutter-io.cn"
109
       url: "https://pub.flutter-io.cn"
117
     source: hosted
110
     source: hosted
118
     version: "0.5.1-dev.4"
111
     version: "0.5.1-dev.4"
112
+  plugin_platform_interface:
113
+    dependency: transitive
114
+    description:
115
+      name: plugin_platform_interface
116
+      url: "https://pub.flutter-io.cn"
117
+    source: hosted
118
+    version: "1.0.2"
119
   provider:
119
   provider:
120
     dependency: "direct main"
120
     dependency: "direct main"
121
     description:
121
     description:
123
       url: "https://pub.flutter-io.cn"
123
       url: "https://pub.flutter-io.cn"
124
     source: hosted
124
     source: hosted
125
     version: "4.0.5"
125
     version: "4.0.5"
126
-  quiver:
127
-    dependency: transitive
128
-    description:
129
-      name: quiver
130
-      url: "https://pub.flutter-io.cn"
131
-    source: hosted
132
-    version: "2.1.3"
133
   sky_engine:
126
   sky_engine:
134
     dependency: transitive
127
     dependency: transitive
135
     description: flutter
128
     description: flutter
191
       url: "https://pub.flutter-io.cn"
184
       url: "https://pub.flutter-io.cn"
192
     source: hosted
185
     source: hosted
193
     version: "2.0.8"
186
     version: "2.0.8"
194
-  xml:
195
-    dependency: transitive
196
-    description:
197
-      name: xml
198
-      url: "https://pub.flutter-io.cn"
199
-    source: hosted
200
-    version: "3.6.1"
201
 sdks:
187
 sdks:
202
   dart: ">=2.7.0 <3.0.0"
188
   dart: ">=2.7.0 <3.0.0"
203
-  flutter: ">=1.12.1"
189
+  flutter: ">=1.12.13 <2.0.0"

+ 1
- 0
pubspec.yaml View File

13
 
13
 
14
   photo_manager: ^0.5.1-dev.2
14
   photo_manager: ^0.5.1-dev.2
15
   provider: ^4.0.5
15
   provider: ^4.0.5
16
+  image_picker: ^0.6.5
16
   # photo_manager:
17
   # photo_manager:
17
   #   git:
18
   #   git:
18
   #     url: https://github.com/CaiJingLong/flutter_photo_manager.git
19
   #     url: https://github.com/CaiJingLong/flutter_photo_manager.git