Skip to content

Commit 127344f

Browse files
authored
[image_picker] Updated README.md with new example (flutter#3044)
1 parent b6a42c2 commit 127344f

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

packages/image_picker/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.7+10
2+
3+
* Updated documentation with code that does not throw an error when image is not picked.
4+
15
## 0.6.7+9
26

37
* Updated the ExifInterface to the AndroidX version to support more file formats;

packages/image_picker/image_picker/README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,22 @@ Add `android:requestLegacyExternalStorage="true"` as an attribute to the `<appli
2929
### Example
3030

3131
``` dart
32+
import 'dart:io';
33+
34+
import 'package:flutter/material.dart';
3235
import 'package:image_picker/image_picker.dart';
3336
37+
void main() => runApp(MyApp());
38+
39+
class MyApp extends StatelessWidget {
40+
@override
41+
Widget build(BuildContext context) {
42+
return MaterialApp(
43+
home: MyHomePage(),
44+
);
45+
}
46+
}
47+
3448
class MyHomePage extends StatefulWidget {
3549
@override
3650
_MyHomePageState createState() => _MyHomePageState();
@@ -44,7 +58,11 @@ class _MyHomePageState extends State<MyHomePage> {
4458
final pickedFile = await picker.getImage(source: ImageSource.camera);
4559
4660
setState(() {
47-
_image = File(pickedFile.path);
61+
if (pickedFile != null) {
62+
_image = File(pickedFile.path);
63+
} else {
64+
print('No image selected.');
65+
}
4866
});
4967
}
5068

packages/image_picker/image_picker/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: image_picker
22
description: Flutter plugin for selecting images from the Android and iOS image
33
library, and taking new pictures with the camera.
44
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker
5-
version: 0.6.7+9
5+
version: 0.6.7+10
66

77
flutter:
88
plugin:

0 commit comments

Comments
 (0)