From 7278fb61f1d1d0c59b083763f65e6b8016e39e11 Mon Sep 17 00:00:00 2001 From: peter <16809252+percula@users.noreply.github.com> Date: Fri, 12 Mar 2021 09:52:58 -0500 Subject: [PATCH] Add null safety to library and example --- example/lib/main.dart | 16 +++--- example/pubspec.lock | 104 ++++++++++++++++++++++++---------- example/pubspec.yaml | 10 +--- example/test/widget_test.dart | 2 +- lib/heic_to_jpg.dart | 4 +- pubspec.lock | 40 ++++++------- pubspec.yaml | 6 +- 7 files changed, 111 insertions(+), 71 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index cca9c7f..f10a866 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -17,23 +17,25 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { String heicUrl = 'https://filesamples.com/samples/image/heic/sample1.heic'; - String jpeg; + String? jpeg; bool initialized = false; // Platform messages are asynchronous, so we initialize in an async method. Future initPlatformState() async { if (initialized) return; initialized = true; - WidgetsBinding.instance.addPostFrameCallback((Duration timeStamp) async { - String tmp = await showDialog( - context: context, child: FutureProgressDialog(downloadAndConvert())); + WidgetsBinding.instance!.addPostFrameCallback((Duration timeStamp) async { + String? tmp = await showDialog( + builder: (context) => FutureProgressDialog(downloadAndConvert()), + context: context, + ); setState(() { jpeg = tmp; }); }); } - Future downloadAndConvert() async { + Future downloadAndConvert() async { File heicFile = await _downloadFile(heicUrl, 'a.heic'); String convertedPath = (await getTemporaryDirectory()).path + "/b.heic"; return HeicToJpg.convert(heicFile.path, jpgPath: convertedPath); @@ -47,8 +49,8 @@ class _MyAppState extends State { title: const Text('Plugin example app'), ), body: Center( - child: (jpeg != null && jpeg.isNotEmpty) - ? Image.file(File(jpeg)) + child: (jpeg != null && jpeg!.isNotEmpty) + ? Image.file(File(jpeg!)) : Text('No Image'), ), ); diff --git a/example/pubspec.lock b/example/pubspec.lock index a487298..436a3ed 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,56 +7,63 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" - cupertino_icons: - dependency: "direct main" + version: "1.15.0" + fake_async: + dependency: transitive description: - name: cupertino_icons + name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" - fake_async: + version: "1.2.0" + ffi: dependency: transitive description: - name: fake_async + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" + file: + dependency: transitive + description: + name: file url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "6.1.0" flutter: dependency: "direct main" description: flutter @@ -87,56 +94,77 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" path_provider: dependency: "direct main" description: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "1.6.8" + version: "2.0.1" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.4+2" + version: "2.0.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "2.0.1" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "3.0.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "2.0.0" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.0" sky_engine: dependency: transitive description: flutter @@ -148,56 +176,70 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" + win32: + dependency: transitive + description: + name: win32 + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.12.13+hotfix.5 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index a32e9eb..e1b7eb3 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -4,16 +4,12 @@ publish_to: 'none' environment: - sdk: ">=2.1.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: sdk: flutter - path_provider: ^1.6.8 - - # 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: ^2.0.1 dev_dependencies: flutter_test: @@ -22,7 +18,7 @@ dev_dependencies: heic_to_jpg: path: ../ - future_progress_dialog: ^0.1.1 + future_progress_dialog: ^0.1.1 # Not null safe, so need to run example with flutter run --no-sound-null-safety # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index 4028223..ca5d8e8 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -19,7 +19,7 @@ void main() { expect( find.byWidgetPredicate( (Widget widget) => widget is Text && - widget.data.startsWith('Running on:'), + widget.data!.startsWith('Running on:'), ), findsOneWidget, ); diff --git a/lib/heic_to_jpg.dart b/lib/heic_to_jpg.dart index e2d4424..a340052 100644 --- a/lib/heic_to_jpg.dart +++ b/lib/heic_to_jpg.dart @@ -9,8 +9,8 @@ class HeicToJpg { /// Get [heicPath] path as an input and return [jpg] path. /// You can set [jpgPath] if you want to set the output file path. /// If you don't set it the output file path is made in cache directory of each platform. - static Future convert(String heicPath, {String jpgPath}) async { - final String jpg = await _channel + static Future convert(String heicPath, {String? jpgPath}) async { + final String? jpg = await _channel .invokeMethod('convert', {"heicPath": heicPath, "jpgPath": jpgPath}); return jpg; } diff --git a/pubspec.lock b/pubspec.lock index b03d310..19e8f69 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -66,21 +66,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -92,56 +92,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.12.0 <2.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index ef047dd..19d7ed9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: heic_to_jpg description: With this library you can convert HEIC/HEIF file to JPEG image easily -version: 0.1.3 +version: 0.2.0 homepage: https://github.com/donguseo/flutter_heic_to_jpg environment: - sdk: ">=2.1.0 <3.0.0" - flutter: ">=1.12.0 <2.0.0" + sdk: '>=2.12.0 <3.0.0' + flutter: ">=2.0.0 <3.0.0" dependencies: flutter: