From 85c5b382fabece6f02c059cf0ebd0ea320bc8548 Mon Sep 17 00:00:00 2001 From: Timur Tharkahov Date: Thu, 6 Jul 2023 18:15:28 -0300 Subject: [PATCH 1/8] fix: possible crash - unstable crash on second received code - unstable crash on timeout --- .../main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt b/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt index 5f3f2d4..e533455 100644 --- a/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt +++ b/android/src/main/kotlin/ru/surfstudio/otp_autofill/OTPPlugin.kt @@ -123,6 +123,7 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi // Get SMS message content val message = data.getStringExtra(SmsRetriever.EXTRA_SMS_MESSAGE) lastResult?.success(message) + lastResult = null } else { // Consent denied. User can type OTC manually. } @@ -130,6 +131,7 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi val phoneNumber = Identity.getSignInClient(context!!).getPhoneNumberFromIntent(data) lastResult?.success(phoneNumber) + lastResult = null } } return true @@ -170,6 +172,7 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi override fun onFailure() { lastResult?.error("408", "Timeout exception", null) + lastResult = null } } } @@ -182,11 +185,15 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi smsRetrieverBroadcastReceiver = SmsRetrieverReceiver().also { it.smsBroadcastReceiverListener = object : SmsRetrieverReceiver.SmsRetrieverBroadcastReceiverListener { override fun onSuccess(sms: String?) { - sms?.let { it -> lastResult?.success(it) } + sms?.let { it -> + lastResult?.success(it) + lastResult = null + } } override fun onFailure() { lastResult?.error("408", "Timeout exception", null) + lastResult = null } } } From 38ec4bac70f82742174079f5cccaff7eb7fa7119 Mon Sep 17 00:00:00 2001 From: Podushkin Vitaliy Date: Tue, 11 Jul 2023 05:37:11 +0700 Subject: [PATCH 2/8] feat(version): added fvm usage --- .fvm/fvm_config.json | 4 ++++ .gitignore | 1 + 2 files changed, 5 insertions(+) create mode 100644 .fvm/fvm_config.json diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json new file mode 100644 index 0000000..6e3d57e --- /dev/null +++ b/.fvm/fvm_config.json @@ -0,0 +1,4 @@ +{ + "flutterSdkVersion": "3.7.6", + "flavors": {} +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 85c4ec3..1e7384b 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ .pub-cache/ .pub/ build/ +.fvm/flutter_sdk # Android related **/android/**/gradle-wrapper.jar From accb6a51de27c197ac6720dbcb6422640f3d2404 Mon Sep 17 00:00:00 2001 From: Podushkin Vitaliy Date: Tue, 11 Jul 2023 05:38:09 +0700 Subject: [PATCH 3/8] feat(version): updated usage for future workflow usage --- .github/workflows/main.yml | 10 +++++++++- .github/workflows/publish_to_pub.yml | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 42a8222..abe4916 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,22 +8,30 @@ on: branches: - main tags-ignore: - - '**' + - "**" jobs: analysis: uses: surfstudio/flutter-ci-workflows/.github/workflows/analysis.yml@main + with: + flutter-version: "3.7.6" testing: needs: analysis uses: surfstudio/flutter-ci-workflows/.github/workflows/testing.yml@main + with: + flutter-version: "3.7.6" secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} build_android_example: needs: analysis uses: surfstudio/flutter-ci-workflows/.github/workflows/build_android_example.yml@main + with: + flutter-version: "3.7.6" build_ios_example: needs: analysis uses: surfstudio/flutter-ci-workflows/.github/workflows/build_ios_example.yml@main + with: + flutter-version: "3.7.6" diff --git a/.github/workflows/publish_to_pub.yml b/.github/workflows/publish_to_pub.yml index f4a0247..793d03f 100644 --- a/.github/workflows/publish_to_pub.yml +++ b/.github/workflows/publish_to_pub.yml @@ -8,6 +8,8 @@ on: jobs: analysis: uses: surfstudio/flutter-ci-workflows/.github/workflows/analysis.yml@main + with: + flutter-version: "3.7.6" testing: needs: analysis From 4151f8c087096b620095608a06dda3aac862d19f Mon Sep 17 00:00:00 2001 From: Podushkin Vitaliy Date: Tue, 11 Jul 2023 13:12:23 +0700 Subject: [PATCH 4/8] feat(version): read version from fvm config --- .github/workflows/main.yml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index abe4916..a7dd816 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,27 +11,40 @@ on: - "**" jobs: + get_fvm_version: + outputs: + fvm_version: ${{ steps.fvm_version.outputs.version }} + name: "Get Flutter version from FVM" + runs-on: ubuntu-latest + steps: + - id: fvm_version + uses: zoexx/github-action-json-file-properties@release + with: + file_path: ".fvm/fvm_config.json" + - run: echo "version=${{steps.fvm_version.outputs.flutterSdkVersion}}" >> "$GITHUB_OUTPUT" + analysis: + needs: get_fvm_version uses: surfstudio/flutter-ci-workflows/.github/workflows/analysis.yml@main with: - flutter-version: "3.7.6" + flutter-version: ${{ needs.get_fvm_version.outputs.output1 }} testing: - needs: analysis + needs: [analysis, get_fvm_version] uses: surfstudio/flutter-ci-workflows/.github/workflows/testing.yml@main with: - flutter-version: "3.7.6" + flutter-version: ${{ needs.get_fvm_version.outputs.output1 }} secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} build_android_example: - needs: analysis + needs: [analysis, get_fvm_version] uses: surfstudio/flutter-ci-workflows/.github/workflows/build_android_example.yml@main with: - flutter-version: "3.7.6" + flutter-version: ${{ needs.get_fvm_version.outputs.output1 }} build_ios_example: - needs: analysis + needs: [analysis, get_fvm_version] uses: surfstudio/flutter-ci-workflows/.github/workflows/build_ios_example.yml@main with: - flutter-version: "3.7.6" + flutter-version: ${{ needs.get_fvm_version.outputs.output1 }} From e39349bae22e16511ad3519299b18c2de9067f12 Mon Sep 17 00:00:00 2001 From: Podushkin Vitaliy Date: Tue, 11 Jul 2023 13:48:59 +0700 Subject: [PATCH 5/8] fix(version): pick flutter version from fvm config --- .github/workflows/main.yml | 14 ++++++++------ .github/workflows/publish_to_pub.yml | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a7dd816..460cb7a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,27 +13,29 @@ on: jobs: get_fvm_version: outputs: - fvm_version: ${{ steps.fvm_version.outputs.version }} + flutter_version: ${{ steps.fvm_version.outputs.flutterSdkVersion }} name: "Get Flutter version from FVM" runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + - id: fvm_version uses: zoexx/github-action-json-file-properties@release with: file_path: ".fvm/fvm_config.json" - - run: echo "version=${{steps.fvm_version.outputs.flutterSdkVersion}}" >> "$GITHUB_OUTPUT" analysis: needs: get_fvm_version uses: surfstudio/flutter-ci-workflows/.github/workflows/analysis.yml@main with: - flutter-version: ${{ needs.get_fvm_version.outputs.output1 }} + flutter-version: ${{ needs.get_fvm_version.outputs.flutter_version }} testing: needs: [analysis, get_fvm_version] uses: surfstudio/flutter-ci-workflows/.github/workflows/testing.yml@main with: - flutter-version: ${{ needs.get_fvm_version.outputs.output1 }} + flutter-version: ${{ needs.get_fvm_version.outputs.flutter_version }} secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} @@ -41,10 +43,10 @@ jobs: needs: [analysis, get_fvm_version] uses: surfstudio/flutter-ci-workflows/.github/workflows/build_android_example.yml@main with: - flutter-version: ${{ needs.get_fvm_version.outputs.output1 }} + flutter-version: ${{ needs.get_fvm_version.outputs.flutter_version }} build_ios_example: needs: [analysis, get_fvm_version] uses: surfstudio/flutter-ci-workflows/.github/workflows/build_ios_example.yml@main with: - flutter-version: ${{ needs.get_fvm_version.outputs.output1 }} + flutter-version: ${{ needs.get_fvm_version.outputs.flutter_version }} diff --git a/.github/workflows/publish_to_pub.yml b/.github/workflows/publish_to_pub.yml index 793d03f..28ef905 100644 --- a/.github/workflows/publish_to_pub.yml +++ b/.github/workflows/publish_to_pub.yml @@ -6,10 +6,24 @@ on: - v* jobs: + get_fvm_version: + outputs: + flutter_version: ${{ steps.fvm_version.outputs.flutterSdkVersion }} + name: "Get Flutter version from FVM" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - id: fvm_version + uses: zoexx/github-action-json-file-properties@release + with: + file_path: ".fvm/fvm_config.json" + analysis: uses: surfstudio/flutter-ci-workflows/.github/workflows/analysis.yml@main with: - flutter-version: "3.7.6" + flutter-version: ${{ needs.get_fvm_version.outputs.flutter_version }} testing: needs: analysis From 6964d974f1068d2f9a5c6a8f3e2331c634f85aac Mon Sep 17 00:00:00 2001 From: Podushkin Vitaliy Date: Tue, 11 Jul 2023 13:59:07 +0700 Subject: [PATCH 6/8] fix(version): up surf_lint_rules to evade invariant_booleans rule --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index c49507e..c40f022 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,7 @@ dev_dependencies: sdk: flutter mocktail: ^0.2.0 - surf_lint_rules: ^1.0.0 + surf_lint_rules: 2.0.0 environment: sdk: ">=2.12.0 <3.0.0" From bd91a7c967e408b6014426db506efff142e3fa64 Mon Sep 17 00:00:00 2001 From: Podushkin Vitaliy Date: Tue, 11 Jul 2023 13:59:07 +0700 Subject: [PATCH 7/8] fix(version): up surf_lint_rules to evade invariant_booleans rule --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index c49507e..9704635 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,7 @@ dev_dependencies: sdk: flutter mocktail: ^0.2.0 - surf_lint_rules: ^1.0.0 + surf_lint_rules: ^2.0.0 environment: sdk: ">=2.12.0 <3.0.0" From cef060721a856ef4c6e05cbf3fd57e3ac19ec993 Mon Sep 17 00:00:00 2001 From: Podushkin Vitaliy Date: Tue, 11 Jul 2023 14:39:24 +0700 Subject: [PATCH 8/8] fix(example): fix example to comply analyzer --- example/lib/main.dart | 33 +++++++++++++++++++++------------ example/pubspec.yaml | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 878c308..342e7a9 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -12,8 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +// ignore_for_file: library_private_types_in_public_api, prefer-match-file-name + import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:otp_autofill/otp_autofill.dart'; import 'package:otp_autofill_example/sample_strategy.dart'; @@ -37,12 +40,7 @@ class _MyAppState extends State { @override void initState() { super.initState(); - _otpInteractor = OTPInteractor(); - _otpInteractor - .getAppSignature() - //ignore: avoid_print - .then((value) => print('signature - $value')); - + _initInteractor(); controller = OTPTextEditController( codeLength: 5, //ignore: avoid_print @@ -59,6 +57,23 @@ class _MyAppState extends State { ); } + Future _initInteractor() async { + _otpInteractor = OTPInteractor(); + + // You can receive your app signature by using this method. + final appSignature = await _otpInteractor.getAppSignature(); + + if (kDebugMode) { + print('Your app signature: $appSignature'); + } + } + + @override + Future dispose() async { + await controller.stopListen(); + super.dispose(); + } + @override Widget build(BuildContext context) { return MaterialApp( @@ -80,10 +95,4 @@ class _MyAppState extends State { ), ); } - - @override - Future dispose() async { - await controller.stopListen(); - super.dispose(); - } } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 6ee5639..e70ff6f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: dev_dependencies: - surf_lint_rules: ^1.0.0 + surf_lint_rules: ^2.0.0 flutter: uses-material-design: true