diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0728902 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +.flutter-plugins +.flutter-plugins-dependencies +.dart_tool/package_config.json +.dart_tool/package_config_subset +.dart_tool/version +android/local.properties +android/local.properties +android/local.properties +ios/Flutter/Generated.xcconfig +ios/Runner/GeneratedPluginRegistrant.h +ios/Runner/GeneratedPluginRegistrant.m +ios/Flutter/flutter_export_environment.sh +android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +android/local.properties +.packages diff --git a/lib/picker.dart b/lib/picker.dart index bd6919d..b619784 100644 --- a/lib/picker.dart +++ b/lib/picker.dart @@ -41,12 +41,11 @@ class Picker { /// /// In Android, the MainActivity can be destroyed for various reasons. If that happens, the result will be lost /// in this call. You can then call [retrieveLostData] when your app relaunches to retrieve the lost data. - static Future pickImage( - {@required ImageSource source, - double maxWidth, - double maxHeight, - int imageQuality}) async { - assert(source != null); + static Future pickImage( + {required ImageSource source, + double? maxWidth, + double? maxHeight, + int? imageQuality}) async { assert(imageQuality == null || (imageQuality >= 0 && imageQuality <= 100)); if (maxWidth != null && maxWidth < 0) { @@ -57,7 +56,7 @@ class Picker { throw ArgumentError.value(maxHeight, 'maxHeight cannot be negative'); } - final String path = await _channel.invokeMethod( + final String? path = await _channel.invokeMethod( 'pickImage', { 'source': source.index, @@ -77,11 +76,10 @@ class Picker { /// /// In Android, the MainActivity can be destroyed for various fo reasons. If that happens, the result will be lost /// in this call. You can then call [retrieveLostData] when your app relaunches to retrieve the lost data. - static Future pickVideo({ - @required ImageSource source, + static Future pickVideo({ + required ImageSource source, }) async { - assert(source != null); - final String path = await _channel.invokeMethod( + final String? path = await _channel.invokeMethod( 'pickVideo', { 'source': source.index, @@ -91,17 +89,15 @@ class Picker { } static Future saveFile( - {@required Uint8List fileData, String title, String description}) async { - assert(fileData != null); - - String filePath = await _channel.invokeMethod( + {required Uint8List fileData, String? title, String? description}) async { + String filePath = (await _channel.invokeMethod( 'saveFile', { 'fileData': fileData, 'title': title, 'description': description }, - ); + ))!; debugPrint("saved filePath:" + filePath); //process ios return filePath if (filePath.startsWith("file://")) { @@ -124,30 +120,30 @@ class Picker { /// * [LostDataResponse], for what's included in the response. /// * [Android Activity Lifecycle](https://developer.android.com/reference/android/app/Activity.html), for more information on MainActivity destruction. static Future retrieveLostData() async { - final Map result = + final Map? result = await _channel.invokeMapMethod('retrieve'); if (result == null) { return LostDataResponse.empty(); } assert(result.containsKey('path') ^ result.containsKey('errorCode')); - final String type = result['type']; + final String? type = result['type']; assert(type == kTypeImage || type == kTypeVideo); - RetrieveType retrieveType; + RetrieveType? retrieveType; if (type == kTypeImage) { retrieveType = RetrieveType.image; } else if (type == kTypeVideo) { retrieveType = RetrieveType.video; } - PlatformException exception; + PlatformException? exception; if (result.containsKey('errorCode')) { exception = PlatformException( code: result['errorCode'], message: result['errorMessage']); } - final String path = result['path']; + final String? path = result['path']; return LostDataResponse( file: path == null ? null : File(path), @@ -182,7 +178,7 @@ class LostDataResponse { /// The file that was lost in a previous [pickImage] or [pickVideo] call due to MainActivity being destroyed. /// /// Can be null if [exception] exists. - final File file; + final File? file; /// The exception of the last [pickImage] or [pickVideo]. /// @@ -191,10 +187,10 @@ class LostDataResponse { /// You should handle this exception as if the [pickImage] or [pickVideo] got an exception when the MainActivity was not destroyed. /// /// Note that it is not the exception that caused the destruction of the MainActivity. - final PlatformException exception; + final PlatformException? exception; /// Can either be [RetrieveType.image] or [RetrieveType.video]; - final RetrieveType type; + final RetrieveType? type; bool _empty = false; } diff --git a/pubspec.lock b/pubspec.lock index 6d0e1d9..391f9f0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,62 +1,55 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.11" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" - collection: + version: "1.2.0" + clock: dependency: transitive description: - name: collection + name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" - convert: + version: "1.1.0" + collection: dependency: transitive description: - name: convert + name: collection url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.15.0" + fake_async: dependency: transitive description: - name: crypto + name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -67,55 +60,39 @@ packages: description: flutter source: sdk version: "0.0.0" - image: + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + js: dependency: transitive description: - name: image + name: js url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0+1" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -127,70 +104,77 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" video_player: dependency: "direct dev" description: name: video_player url: "https://pub.dartlang.org" source: hosted - version: "0.10.1+5" - xml: + version: "2.0.2" + video_player_platform_interface: dependency: transitive description: - name: xml + name: video_player_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "4.0.0" + video_player_web: + dependency: transitive + description: + name: video_player_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" sdks: - dart: ">=2.4.0 <3.0.0" - flutter: ">=1.10.0 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/pubspec.yaml b/pubspec.yaml index 96f2533..785b4bf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: picker description: Flutter plugin for selecting images from the Android and iOS, taking new pictures with the camera and saves on Gallery homepage: https://github.com/jonataslaw/picker -version: 1.0.3+1 +version: 2.0.0+1 flutter: plugin: @@ -17,10 +17,10 @@ dependencies: sdk: flutter dev_dependencies: - video_player: 0.10.1+5 + video_player: ^2.0.2 flutter_test: sdk: flutter environment: - sdk: ">=2.0.0-dev.28.0 <3.0.0" - flutter: ">=1.10.0 <2.0.0" + sdk: '>=2.12.0 <3.0.0' + flutter: ">=1.10.0 <3.0.0" diff --git a/test/picker_test.dart b/test/picker_test.dart index d4b09c4..8ec03db 100644 --- a/test/picker_test.dart +++ b/test/picker_test.dart @@ -180,7 +180,7 @@ void main() { }); final LostDataResponse response = await Picker.retrieveLostData(); expect(response.type, RetrieveType.image); - expect(response.file.path, '/example/path'); + expect(response.file!.path, '/example/path'); }); test('retrieveLostData get error response', () async { @@ -193,8 +193,8 @@ void main() { }); final LostDataResponse response = await Picker.retrieveLostData(); expect(response.type, RetrieveType.video); - expect(response.exception.code, 'test_error_code'); - expect(response.exception.message, 'test_error_message'); + expect(response.exception!.code, 'test_error_code'); + expect(response.exception!.message, 'test_error_message'); }); test('retrieveLostData get null response', () async {