Skip to content

Commit 1fad136

Browse files
Chris YangPark Sung Min
Chris Yang
authored and
Park Sung Min
committed
[image_picker] more documentations and tests (flutter#2261)
1 parent 1daa29e commit 1fad136

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

packages/image_picker/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.1+11
2+
3+
* Stability and Maintainability: update documentations, add unit tests.
4+
15
## 0.6.1+10
26

37
* iOS: Fix image orientation problems when scaling images.

packages/image_picker/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
A Flutter plugin for iOS and Android for picking images from the image library,
66
and taking new pictures with the camera.
77

8-
*Note*: This plugin is still under development, and some APIs might not be available yet. [Feedback welcome](https://github.com/flutter/flutter/issues) and [Pull Requests](https://github.com/flutter/plugins/pulls) are most welcome!
9-
108
## Installation
119

1210
First, add `image_picker` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/).
@@ -67,7 +65,7 @@ class _MyHomePageState extends State<MyHomePage> {
6765

6866
### Handling MainActivity destruction on Android
6967

70-
Android system -- although very rarely -- sometimes kills the MainActivity after the image_picker finishes. When this happens, we lost the data selected from the image_picker. You can use `retrieveLostData` to retrieve the lost data in this situation. For example:
68+
Android system -- although very rarely -- sometimes kills the MainActivity after the image_picker finishes. When this happens, we lost the data selected from the image_picker. You can use `retrieveLostData` to retrieve the lost data in this situation. For example:
7169

7270
```dart
7371
Future<void> retrieveLostData() async {

packages/image_picker/lib/image_picker.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ enum ImageSource {
2020
gallery,
2121
}
2222

23+
/// Provides an easy way to pick an image/video from the image library,
24+
/// or to take a picture/video with the camera.
2325
class ImagePicker {
2426
static const MethodChannel _channel =
2527
MethodChannel('plugins.flutter.io/image_picker');

packages/image_picker/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors:
55
- Flutter Team <[email protected]>
66
- Rhodes Davis Jr. <[email protected]>
77
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker
8-
version: 0.6.1+10
8+
version: 0.6.1+11
99

1010
flutter:
1111
plugin:

packages/image_picker/test/image_picker_test.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,33 @@ void main() {
143143
});
144144
});
145145

146+
group('#pickVideo', () {
147+
test('passes the image source argument correctly', () async {
148+
await ImagePicker.pickVideo(source: ImageSource.camera);
149+
await ImagePicker.pickVideo(source: ImageSource.gallery);
150+
151+
expect(
152+
log,
153+
<Matcher>[
154+
isMethodCall('pickVideo', arguments: <String, dynamic>{
155+
'source': 0,
156+
}),
157+
isMethodCall('pickVideo', arguments: <String, dynamic>{
158+
'source': 1,
159+
}),
160+
],
161+
);
162+
});
163+
164+
test('handles a null image path response gracefully', () async {
165+
channel.setMockMethodCallHandler((MethodCall methodCall) => null);
166+
167+
expect(
168+
await ImagePicker.pickVideo(source: ImageSource.gallery), isNull);
169+
expect(await ImagePicker.pickVideo(source: ImageSource.camera), isNull);
170+
});
171+
});
172+
146173
group('#retrieveLostData', () {
147174
test('retrieveLostData get success response', () async {
148175
channel.setMockMethodCallHandler((MethodCall methodCall) async {

0 commit comments

Comments
 (0)