auto_sms_verification 0.0.8 copy "auto_sms_verification: ^0.0.8" to clipboard
auto_sms_verification: ^0.0.8 copied to clipboard

PlatformAndroid

Flutter package for automatic OTP verification using SMS Retriever API, enhancing user experience on Android.

example/lib/main.dart

import 'dart:async';

import 'package:auto_sms_verification/auto_sms_verification.dart';
import 'package:flutter/material.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _smsCode = "";

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  @override
  void dispose() {
    AutoSmsVerification.stopListening();

    super.dispose();
  }

  Future<void> initPlatformState() async {
    var appSignature = await AutoSmsVerification.appSignature();
    print(['appSignature is ', appSignature]);
    var smsCode = await AutoSmsVerification.startListeningSms();
    setState(() {
      _smsCode = getCode(smsCode) ?? '';
    });
  }

  String? getCode(String? sms) {
    print("SMS: ${sms}");
    if (sms != null) {
      final intRegex = RegExp(r'\d+', multiLine: true);
      final code = intRegex.allMatches(sms).first.group(0);

      return code;
    }
    return null;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('SMS Code is: $_smsCode\n'),
        ),
      ),
    );
  }
}
10
likes
160
points
45
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter package for automatic OTP verification using SMS Retriever API, enhancing user experience on Android.

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on auto_sms_verification

Packages that implement auto_sms_verification