get_sms_otp_consent 0.0.3+3 copy "get_sms_otp_consent: ^0.0.3+3" to clipboard
get_sms_otp_consent: ^0.0.3+3 copied to clipboard

PlatformAndroid

A Flutter plugin to provide SMS code auto-retrieval and device's phone number extraction

example/lib/main.dart

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



//Regex("(\\d{6})")
void main() {
  runApp(const MyApp());
}

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

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

class _MyAppState extends State<MyApp> {
  String? _receivedSms ;
  String? _phoneNumber ;
  final _smsConsentPlugin = GetSmsOtpConsent();
  @override
  void initState() {
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('SMS Consent Example'),
        ),
        body: Center(
          child: Column(
            children: [
              TextButton(onPressed: ()async{
                //_launchCustomActivity();
                _phoneNumber= await _smsConsentPlugin.getPhoneNumber();
                setState(() {

                });
              }, child: const Text("Get Phone Number")),
              TextButton(onPressed: ()async{
                //_launchCustomActivity();
                await _smsConsentPlugin.initializeSmsConsent("OtpSMS");
                _receivedSms = await _smsConsentPlugin.getOtpSmsMessage();
                setState(() {

                });
              }, child: const Text("Listen Otp")),
              TextButton(onPressed: (){
                //_disposeActivity();
                _smsConsentPlugin.disposeSmsConsent();
              }, child: const Text("Dispose ListenOtp")),
              if(_receivedSms!=null)Text(_receivedSms!),
              if(_phoneNumber!=null)Text(_phoneNumber!)
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
150
points
1
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to provide SMS code auto-retrieval and device's phone number extraction

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on get_sms_otp_consent

Packages that implement get_sms_otp_consent