Skip to content

Commit

Permalink
prepare v2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
TesteurManiak committed Mar 22, 2022
1 parent 807673b commit a087cea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.1.1 - [22/03/2022]

* Updated example project to null safety.
* Fixed potential issue with null value for methods `getImageInfo`, `getVideoAsBytes` and `getVideoInfo`.

## 2.1.0 - [14/12/2021]

* Deprecated `getImage`, `getMultiImages` and `getVideo` methods.
Expand Down
6 changes: 3 additions & 3 deletions example/lib/sample/sample_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ class _SamplePageState extends State<SamplePage> {

Future<void> _getImgInfo() async {
final infos = await ImagePickerWeb.getImageInfo;
final data = infos.data;
final data = infos?.data;
if (data != null) {
setState(() {
_pickedImages.clear();
_pickedImages.add(Image.memory(data, semanticLabel: infos.fileName));
_imageInfo = '${infos.toJson()}';
_pickedImages.add(Image.memory(data, semanticLabel: infos?.fileName));
_imageInfo = '${infos?.toJson()}';
});
}
}
Expand Down
17 changes: 8 additions & 9 deletions lib/image_picker_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,11 @@ class ImagePickerWeb {
/// Help to retrieve further image's informations about your picked source.
///
/// Return an object [MediaInfo] containing image's informations.
static Future<MediaInfo> get getImageInfo async {
static Future<MediaInfo?> get getImageInfo async {
final data =
await (_methodChannel.invokeMapMethod<String, dynamic>('pickImage'));
return MediaInfo.fromJson(data!);
if (data == null) return null;
return MediaInfo.fromJson(data);
}

/// Picker that allows multi-image selection. Here are the different instance
Expand Down Expand Up @@ -286,11 +287,9 @@ class ImagePickerWeb {
static Future<Uint8List?> getVideoAsBytes() async {
final data =
await _methodChannel.invokeMapMethod<String, dynamic>('pickVideo');
if (data != null) {
final imageData = base64.decode(data['data']);
return imageData;
}
return null;
if (data == null) return null;
final imageData = base64.decode(data['data']);
return imageData;
}

/// Picker that close after selecting 1 video and return a [html.File] of the
Expand All @@ -305,7 +304,7 @@ class ImagePickerWeb {
static Future<MediaInfo?> get getVideoInfo async {
final data =
await _methodChannel.invokeMapMethod<String, dynamic>('pickVideo');
if (data != null) return MediaInfo.fromJson(data);
return null;
if (data == null) return null;
return MediaInfo.fromJson(data);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: image_picker_web
description: Flutter Web Plugin to pick Images (as Widget, File or Uint8List)
and Videos (as File or Uint8List)
version: 2.1.0
version: 2.1.1
repository: https://github.com/Ahmadre/image_picker_web

environment:
Expand Down

0 comments on commit a087cea

Please sign in to comment.