Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: possible crash #57

Merged
merged 11 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutterSdkVersion": "3.7.6",
"flavors": {}
}
31 changes: 27 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,45 @@ on:
branches:
- main
tags-ignore:
- '**'
- "**"

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:
needs: get_fvm_version
uses: surfstudio/flutter-ci-workflows/.github/workflows/analysis.yml@main
with:
flutter-version: ${{ needs.get_fvm_version.outputs.flutter_version }}

testing:
needs: analysis
needs: [analysis, get_fvm_version]
uses: surfstudio/flutter-ci-workflows/.github/workflows/testing.yml@main
with:
flutter-version: ${{ needs.get_fvm_version.outputs.flutter_version }}
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: ${{ needs.get_fvm_version.outputs.flutter_version }}

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: ${{ needs.get_fvm_version.outputs.flutter_version }}
16 changes: 16 additions & 0 deletions .github/workflows/publish_to_pub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +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: ${{ needs.get_fvm_version.outputs.flutter_version }}

testing:
needs: analysis
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
.pub-cache/
.pub/
build/
.fvm/flutter_sdk

# Android related
**/android/**/gradle-wrapper.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ 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.
}
credentialPickerRequest -> if (resultCode == Activity.RESULT_OK && data != null) {
val phoneNumber =
Identity.getSignInClient(context!!).getPhoneNumberFromIntent(data)
lastResult?.success(phoneNumber)
lastResult = null
}
}
return true
Expand Down Expand Up @@ -170,6 +172,7 @@ public class OTPPlugin : FlutterPlugin, MethodCallHandler, PluginRegistry.Activi

override fun onFailure() {
lastResult?.error("408", "Timeout exception", null)
lastResult = null
}
}
}
Expand All @@ -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
}
}
}
Expand Down
33 changes: 21 additions & 12 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -37,12 +40,7 @@ class _MyAppState extends State<MyApp> {
@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
Expand All @@ -59,6 +57,23 @@ class _MyAppState extends State<MyApp> {
);
}

Future<void> _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<void> dispose() async {
await controller.stopListen();
super.dispose();
}

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand All @@ -80,10 +95,4 @@ class _MyAppState extends State<MyApp> {
),
);
}

@override
Future<void> dispose() async {
await controller.stopListen();
super.dispose();
}
}
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:


dev_dependencies:
surf_lint_rules: ^1.0.0
surf_lint_rules: ^2.0.0

flutter:
uses-material-design: true
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down