From 2d4b9ad15cac851e6e93f59f5979d578db40ad91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joa=CC=83o=20Vitor=20R?= Date: Wed, 3 Mar 2021 20:18:18 -0300 Subject: [PATCH] nullsafety --- CHANGELOG.md | 4 + example/.flutter-plugins-dependencies | 1 + .../ios/Flutter/flutter_export_environment.sh | 13 ++ example/pubspec.lock | 148 +++++++----------- lib/flutter_des.dart | 22 +-- pubspec.lock | 138 ++++++---------- pubspec.yaml | 4 +- test/flutter_des_test.dart | 6 +- 8 files changed, 135 insertions(+), 201 deletions(-) create mode 100644 example/.flutter-plugins-dependencies create mode 100755 example/ios/Flutter/flutter_export_environment.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index e1d1745..c25fa4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.2 + +* support nullsafety + ## 1.1.1 * support swift 5 diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies new file mode 100644 index 0000000..cdf82d6 --- /dev/null +++ b/example/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_des","path":"/Users/joaov/StudioProjects/flutter_des/","dependencies":[]}],"android":[{"name":"flutter_des","path":"/Users/joaov/StudioProjects/flutter_des/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_des","dependencies":[]}],"date_created":"2021-03-03 20:18:02.320662","version":"2.0.0"} \ No newline at end of file diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh new file mode 100755 index 0000000..b3ee5a5 --- /dev/null +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=/Users/joaov/flutter" +export "FLUTTER_APPLICATION_PATH=/Users/joaov/StudioProjects/flutter_des/example" +export "FLUTTER_TARGET=lib/main.dart" +export "FLUTTER_BUILD_DIR=build" +export "SYMROOT=${SOURCE_ROOT}/../build/ios" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=false" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.packages" diff --git a/example/pubspec.lock b/example/pubspec.lock index 68976bb..9b984ae 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,69 +1,62 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.0.11" - args: - dependency: transitive - description: - name: args - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.5.2" async: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + 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.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" - charcode: + version: "2.1.0" + characters: dependency: transitive description: - name: charcode - url: "https://pub.flutter-io.cn" + name: characters + url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" - collection: + version: "1.1.0" + charcode: dependency: transitive description: - name: collection - url: "https://pub.flutter-io.cn" + name: charcode + url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" - convert: + version: "1.2.0" + clock: dependency: transitive description: - name: convert - url: "https://pub.flutter-io.cn" + name: clock + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" - crypto: + version: "1.1.0" + collection: dependency: transitive description: - name: crypto - url: "https://pub.flutter-io.cn" + name: collection + url: "https://pub.dartlang.org" source: hosted - version: "2.1.3" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" source: hosted - version: "0.1.2" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -75,61 +68,33 @@ packages: path: ".." relative: true source: path - version: "1.1.1" + version: "1.1.2" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" - image: - dependency: transitive - description: - name: image - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.1.4" matcher: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.8.0+1" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.0.5" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -139,64 +104,57 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" - source: hosted - version: "2.0.8" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "2.1.0" sdks: - dart: ">=2.4.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/lib/flutter_des.dart b/lib/flutter_des.dart index 8472196..e762964 100644 --- a/lib/flutter_des.dart +++ b/lib/flutter_des.dart @@ -9,22 +9,22 @@ const String _iv = '01234567'; class FlutterDes { static const MethodChannel _channel = const MethodChannel('flutter_des'); - static Future encrypt(String string, String key, + static Future encrypt(String string, String key, {String iv = _iv}) async { if (string.isEmpty) { return null; } - final Uint8List crypt = + final Uint8List? crypt = await _channel.invokeMethod('encrypt', [string, key, iv]); return crypt; } - static Future encryptToHex(String string, String key, + static Future encryptToHex(String string, String key, {String iv = _iv}) async { if (string.isEmpty) { return ''; } - final String crypt = + final String? crypt = await _channel.invokeMethod('encryptToHex', [string, key, iv]); return crypt; } @@ -34,27 +34,27 @@ class FlutterDes { if (string.isEmpty) { return ''; } - final String crypt = base64Encode(await encrypt(string, key, iv: iv)); + final String crypt = base64Encode(await (encrypt(string, key, iv: iv) as FutureOr>)); return crypt; } - static Future decrypt(Uint8List data, String key, + static Future decrypt(Uint8List data, String key, {String iv = _iv}) async { - final String crypt = + final String? crypt = await _channel.invokeMethod('decrypt', [data, key, iv]); return crypt; } - static Future decryptFromHex(String hex, String key, + static Future decryptFromHex(String? hex, String key, {String iv = _iv}) async { - final String crypt = + final String? crypt = await _channel.invokeMethod('decryptFromHex', [hex, key, iv]); return crypt; } - static Future decryptFromBase64(String base64, String key, + static Future decryptFromBase64(String base64, String key, {String iv = _iv}) async { - final String crypt = await decrypt(base64Decode(base64), key, iv: iv); + final String? crypt = await decrypt(base64Decode(base64), key, iv: iv); return crypt; } } diff --git a/pubspec.lock b/pubspec.lock index c57bb09..49a0ce6 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.flutter-io.cn" - source: hosted - version: "2.0.11" - args: - dependency: transitive - description: - name: args - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.5.2" async: dependency: transitive description: name: async - url: "https://pub.flutter-io.cn" + 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.flutter-io.cn" + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" - collection: + version: "1.2.0" + clock: dependency: transitive description: - name: collection - url: "https://pub.flutter-io.cn" + name: clock + url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" - convert: + version: "1.1.0" + collection: dependency: transitive description: - name: convert - url: "https://pub.flutter-io.cn" + 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 - url: "https://pub.flutter-io.cn" + 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,27 @@ packages: description: flutter source: sdk version: "0.0.0" - image: - dependency: transitive - description: - name: image - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.1.4" matcher: dependency: transitive description: name: matcher - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0" path: dependency: transitive description: name: path - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.6.4" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.8.0+1" - petitparser: - dependency: transitive - description: - name: petitparser - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.0.5" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -125,64 +90,57 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" + 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.flutter-io.cn" - source: hosted - version: "2.0.8" - xml: - dependency: transitive - description: - name: xml - url: "https://pub.flutter-io.cn" + url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "2.1.0" sdks: - dart: ">=2.4.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index bf9f80d..acbceba 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: flutter_des description: Java, android, ios, get the same result by DES encryption and decryption. -version: 1.1.1 +version: 1.1.2 homepage: https://github.com/OctMon/flutter_des environment: - sdk: ">=2.1.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: flutter: diff --git a/test/flutter_des_test.dart b/test/flutter_des_test.dart index bb7eafd..8b2761b 100644 --- a/test/flutter_des_test.dart +++ b/test/flutter_des_test.dart @@ -12,9 +12,9 @@ void main() { setUp(() { channel.setMockMethodCallHandler((MethodCall methodCall) async { - String string = methodCall.arguments[0]; - String key = methodCall.arguments[1]; - String iv = methodCall.arguments[2]; + String? string = methodCall.arguments[0]; + String? key = methodCall.arguments[1]; + String? iv = methodCall.arguments[2]; switch (methodCall.method) { case 'encryptToHex': return '0A7233FC34EA762B933F41AA27A3614113A1AB6DD91515847526EE339B91A8F07B4C662CA613BC21778316C68B4517C946FB0DDAF16CB56BCD062877736A0FC18B8E65E9E09DC35D9B4727F4CEB33958';