FLUTTER ECOSYSTEM

tazik561/alt_sms_auto_fill

tazik561/alt_sms_auto_fill open-source repository details.

alt_sms_auto_fill 项目封面
Stars
13
Forks
10
最近推送(UTC)
2023年2月23日
项目状态
未归档
Ali Tazik GitHub avatar
GITHUB User

Ali Tazik ↗

freelancerArmenia
语言JavaDartSwiftRubyObjective-C

此仓库发布的插件

使用的依赖

依赖清单 2 项
  • flutter{"sdk":"flutter"}
  • flutter_test开发依赖{"sdk":"flutter"}

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

alt_sms_autofill

Alt Sms Autofill.

Getting Started

This project is for getting new arrived sms and shows on application. Sms completely return into application and you can split it as you want.

https://raw.githubusercontent.com/tazik561/alt_sms_auto_fill/main/images/alt_sms_autofill.gif?raw=true

Usage

Add it to your pubspec.yaml file:


dependencies:

alt_sms_autofill: version

In your library add the following import:


import 'package:alt_sms_autofill/alt_sms_autofill.dart';

Here is an example how to use:

class _MyAppState extends State<MyApp> {
  String _commingSms = 'Unknown'; 

  Future<void> initSmsListener() async {

    String commingSms;
    try {
      commingSms = await AltSmsAutofill().listenForSms;
    } on PlatformException {
      commingSms = 'Failed to get Sms.';
    }
    if (!mounted) return;

    setState(() {
      _commingSms = commingSms;
    });

  }

  @override
  void dispose() {

    AltSmsAutofill().unregisterListener();
    super.dispose();

  }

  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('AltAutoFill example app'),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Center(
              child: Text('Running on: $_commingSms\n'),
            ),
            TextButton(
              child: Text('Listen for sms code'),
              onPressed: initSmsListener,
            ),
          ],
        ),
      ),
    );

  }

parameters

  • listenForCode() to listen for the SMS code from the native plugin when SMS is received.
  • unregisterListener() to unregister the broadcast receiver, need to be called on your dispose.

#ff packages pub publish