From d08c0896a835b2786ba7b582b54c1bc4cb60e4e9 Mon Sep 17 00:00:00 2001 From: Kyaw Date: Sun, 4 Apr 2021 10:33:35 +0800 Subject: [PATCH] null safety upgrade --- example/lib/main.dart | 14 ++++++++------ example/pubspec.yaml | 8 ++++---- lib/share_extend.dart | 16 ++++++++-------- pubspec.yaml | 4 ++-- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index fa3b464..9cc9d07 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -17,6 +17,8 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { + final _picker = ImagePicker(); + @override void initState() { super.initState(); @@ -43,10 +45,10 @@ class _MyAppState extends State { ), RaisedButton( onPressed: () async { - File f = await ImagePicker.pickImage( + final res = await _picker.getImage( source: ImageSource.gallery); - if (f != null) { - ShareExtend.share(f.path, "image", + if (res.path != null) { + ShareExtend.share(res.path, "image", sharePanelTitle: "share image title", subject: "share image subject"); } @@ -55,10 +57,10 @@ class _MyAppState extends State { ), RaisedButton( onPressed: () async { - File f = await ImagePicker.pickVideo( + final res = await _picker.getVideo( source: ImageSource.gallery); - if (f != null) { - ShareExtend.share(f.path, "video"); + if (res.path != null) { + ShareExtend.share(res.path, "video"); } }, child: Text("share video"), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 994381c..27db4d2 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -18,10 +18,10 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.2 - path_provider: ^1.4.0 - multi_image_picker: ^4.6.1 - image_picker: ^0.6.3 + cupertino_icons: ^1.0.2 + path_provider: ^2.0.1 + multi_image_picker: ^4.8.00 + image_picker: ^0.7.4 # image_picker: # git: # url: git@github.com:miguelpruivo/plugins.git diff --git a/lib/share_extend.dart b/lib/share_extend.dart index a34379e..25ff1ea 100644 --- a/lib/share_extend.dart +++ b/lib/share_extend.dart @@ -25,8 +25,8 @@ class ShareExtend { /// [extraText] only supports android for Intent.EXTRA_TEXT when sharing image or file. /// static Future shareMultiple(List list, String type, - {Rect sharePositionOrigin, - String sharePanelTitle, + {Rect? sharePositionOrigin, + String? sharePanelTitle, String subject = "", String extraText = ""}) { assert(list != null && list.isNotEmpty); @@ -48,8 +48,8 @@ class ShareExtend { /// [extraText] only supports android for Intent.EXTRA_TEXT when sharing image or file. /// static Future share(String text, String type, - {Rect sharePositionOrigin, - String sharePanelTitle, + {Rect? sharePositionOrigin, + String? sharePanelTitle, String subject = "", String extraText = ""}) { assert(text != null); @@ -66,10 +66,10 @@ class ShareExtend { } static Future _shareInner(List list, String type, - {Rect sharePositionOrigin, - String sharePanelTitle, - String subject, - String extraText}) { + {Rect? sharePositionOrigin, + String? sharePanelTitle, + String? subject, + String? extraText}) { assert(list != null && list.isNotEmpty); final Map params = { 'list': list, diff --git a/pubspec.yaml b/pubspec.yaml index 6c34393..a07521f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,11 +5,11 @@ author: zhouteng homepage: https://github.com/zhouteng0217/ShareExtend environment: - sdk: ">=2.0.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' flutter: ">=1.10.0 <2.0.0" dependencies: - meta: ^1.0.5 + meta: ^1.3.0 flutter: sdk: flutter