Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[image_picker] more documentations and tests. #2261

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.1+11

* Stability and Maintainability: update documentations, add unit tests.

## 0.6.1+10

* iOS: Fix image orientation problems when scaling images.
Expand Down
4 changes: 1 addition & 3 deletions packages/image_picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
A Flutter plugin for iOS and Android for picking images from the image library,
and taking new pictures with the camera.

*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!

## Installation

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

### Handling MainActivity destruction on Android

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:
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:

```dart
Future<void> retrieveLostData() async {
Expand Down
2 changes: 2 additions & 0 deletions packages/image_picker/lib/image_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ enum ImageSource {
gallery,
}

/// Provides an easy way to pick an image/video from the image library,
/// or to take a picture/video with the camera.
class ImagePicker {
static const MethodChannel _channel =
MethodChannel('plugins.flutter.io/image_picker');
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors:
- Flutter Team <[email protected]>
- Rhodes Davis Jr. <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker
version: 0.6.1+10
version: 0.6.1+11

flutter:
plugin:
Expand Down
27 changes: 27 additions & 0 deletions packages/image_picker/test/image_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,33 @@ void main() {
});
});

group('#pickVideo', () {
test('passes the image source argument correctly', () async {
await ImagePicker.pickVideo(source: ImageSource.camera);
await ImagePicker.pickVideo(source: ImageSource.gallery);

expect(
log,
<Matcher>[
isMethodCall('pickVideo', arguments: <String, dynamic>{
'source': 0,
}),
isMethodCall('pickVideo', arguments: <String, dynamic>{
'source': 1,
}),
],
);
});

test('handles a null image path response gracefully', () async {
channel.setMockMethodCallHandler((MethodCall methodCall) => null);

expect(
await ImagePicker.pickVideo(source: ImageSource.gallery), isNull);
expect(await ImagePicker.pickVideo(source: ImageSource.camera), isNull);
});
});

group('#retrieveLostData', () {
test('retrieveLostData get success response', () async {
channel.setMockMethodCallHandler((MethodCall methodCall) async {
Expand Down