otp_autofill 0.0.1-dev.4 copy "otp_autofill: ^0.0.1-dev.4" to clipboard
otp_autofill: ^0.0.1-dev.4 copied to clipboard

outdated

Android implementation of OTP autofill with using User Consent API and Retriever API. Add possibility to receive OTP code from another input.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:otp_autofill/otp_interactor.dart';
import 'package:otp_autofill/otp_text_edit_controller.dart';
import 'package:otp_autofill_example/sample_strategy.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  OTPTextEditController controller;
  final scaffoldKey = GlobalKey();

  @override
  void initState() {
    super.initState();
    OTPInteractor.getAppSignature()
        //ignore: avoid_print
        .then((value) => print('signature - $value'));
    controller = OTPTextEditController(
      codeLength: 5,
      //ignore: avoid_print
      onCodeReceive: (code) => print('Your Application receive code - $code'),
    )..startListenUserConsent(
        (code) {
          final exp = RegExp(r'(\d{5})');
          return exp.stringMatch(code ?? '') ?? '';
        },
        strategies: [
          SampleStrategy(),
        ],
      );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        key: scaffoldKey,
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Padding(
            padding: const EdgeInsets.all(40.0),
            child: TextField(
              textAlign: TextAlign.center,
              keyboardType: TextInputType.number,
              controller: controller,
            ),
          ),
        ),
      ),
    );
  }

  @override
  Future<void> dispose() async {
    await controller.stopListen();
    super.dispose();
  }
}
206
likes
0
pub points
97%
popularity

Publisher

verified publishersurf.ru

Android implementation of OTP autofill with using User Consent API and Retriever API. Add possibility to receive OTP code from another input.

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on otp_autofill