sms_autofill 1.0.0

sms_autofill #

pub package Flutter plugin to provide SMS code autofill support.

For iOS, this package is not needed as the SMS autofill is provided by default, but not for Android, that's where this package is useful.

No permission to read SMS messages is asked to the user as there no need thanks to SMSRetriever API.

Usage #

You have two widgets at your disposable for autofill an SMS code, PinFieldAutoFill and TextFieldPinAutoFill.

Just before you sent your phone number to the backend, you need to let know the plugin that it need to listen for the SMS with the code.

To do that you need to do:

await SmsAutoFill().listenForCode;

This will listen for the SMS with the code during 5 minutes and when received, autofill the following widget.

PinFieldAutoFill #

PinFieldAutoFill

PinFieldAutoFill(
                decoration: // UnderlineDecoration, BoxLooseDecoration or BoxTightDecoration see https://github.com/TinoGuo/pin_input_text_field for more info,
                currentCode: // prefill with a code
                onCodeSubmitted: //code submitted callback
                onCodeChanged: //code changed callback
                codeLength: //code length, default 6
              ),

TextFieldPinAutoFill #

TextFieldPinAutoFill

TextFieldPinAutoFill(
                decoration: // basic InputDecoration
                currentCode: // prefill with a code
                onCodeSubmitted: //code submitted callback
                onCodeChanged: //code changed callback
                codeLength: //code length, default 6
              ),

Android SMS constraint #

For the code to be receive, it need to follow some rules as describe here: https://developers.google.com/identity/sms-retriever/verify

  • Be no longer than 140 bytes
  • Begin with the prefix <#>
  • Contain a one-time code that the client sends back to your server to complete the verification flow
  • End with an 11-character hash string that identifies your app

One example of SMS would be:

<#> ExampleApp: Your code is 123456
FA+9qCX9VSu

Helper #

PhoneFieldHint [Android only]

PhoneFieldHint is a widget that will allow you ask for system phone number and autofill the widget if a phone is choosen by the user.

Phone hint

Custom CodeAutoFill #

If you want to create a custom widget that will autofill with the sms code, you can use the CodeAutoFill mixin that will offer you:

  • listenForCode() to listen for the SMS code from the native plugin when SMS is received, need to be called on your initState.
  • cancel() to dispose the subscription of the SMS code from the native plugin, need to be called on your dispose.
  • codeUpdated() called when the code is received, you can access the value with the field code.

1.0.0 #

  • Android X migration.

0.0.1 #

  • Initial release.

example/README.md

sms_autofill_example #

Demonstrates how to use the sms_autofill plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  sms_autofill: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:sms_autofill/sms_autofill.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
82
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
81
Overall:
Weighted score of the above. [more]
87
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/sms_autofill.dart. (-0.50 points)

Analysis of lib/sms_autofill.dart reported 1 hint:

line 16 col 35: This function has a return type of 'Future', but doesn't end with a return statement.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (pin_input_text_field).

The package description is too short. (-9 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
pin_input_text_field ^0.3.0 0.3.1 1.0.1
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8

Admin