otp_consent 2.0.1 copy "otp_consent: ^2.0.1" to clipboard
otp_consent: ^2.0.1 copied to clipboard

PlatformAndroid

Flutter plugin to provide SMS User Consent API gives the content of a single SMS message to us if the user gives permission.

example/lib/main.dart

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

void main() => runApp(MaterialApp(
      home: MyApp(),
    ));

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with OtpConsentAutoFill {
  String? otp;
  bool startListen = false;

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin otp consent example app'),
        ),
        body: Container(
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisSize: MainAxisSize.max,
              children: <Widget>[
                MaterialButton(
                  color: Colors.red,
                  textColor: Colors.white,
                  child: Text(startListen ? 'Started' : 'Start Listening'),
                  onPressed: () async {
                    var startListen = await startOtpConsent();
                    setState(() {
                      this.startListen = startListen;
                    });
                  },
                ),
                Text(otp ?? ""),
              ],
            ),
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  void smsReceived(String? sms) {
    setState(() {
      otp = sms;
      startListen = false;
    });
  }
}
1
likes
120
pub points
35%
popularity

Publisher

verified publisherhuynn109.me

Flutter plugin to provide SMS User Consent API gives the content of a single SMS message to us if the user gives permission.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, test

More

Packages that depend on otp_consent