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

outdated

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 'dart:async';

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

void main() => runApp(MyApp());

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

class _MyAppState extends State<MyApp> with OtpConsentAutoFill {
  var otpConsent = OtpConsent();
  String _platformVersion = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await otpConsent.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @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>[
                Text('Running on: $_platformVersion'),
                MaterialButton(
                  color: Colors.red,
                  textColor: Colors.white,
                  child: Text('Start Listening'),
                  onPressed: () async {
                    startSmsListening();
                  },
                )
              ],
            ),
          ),
        ),
      ),
    );
  }

  @override
  void smsReceived(String sms) {
    print(sms);
  }

  @override
  void dispose() {
    stopSmsListen();
    super.dispose();
  }
}
1
likes
30
points
6
downloads

Publisher

verified publisherhuynn109.me

Weekly Downloads

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

Documentation

License

unknown (license)

Dependencies

flutter

More

Packages that depend on otp_consent

Packages that implement otp_consent