flulm_auth 2.1.0 copy "flulm_auth: ^2.1.0" to clipboard
flulm_auth: ^2.1.0 copied to clipboard

The version of the flutter SDK licensed by lemapay is currently only available for the Android system, to be added to the iOS system call.

example/lib/main.dart

import 'package:flulm_auth/flulm_auth.dart' as flulmAuth;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
//import 'package:flutter_stetho/flutter_stetho.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _code = 'Unknown';
  String _appId = "1911131949173836111";
  bool _isInstalled = false;

  @override
  void initState() {
    super.initState();
//    Stetho.initialize();
    flulmAuth.register(appId: _appId);
    flulmAuth.responseFromAuth.listen((data) {
      setState(() {
        _code = data.code;
      });
    });
    flulmAuth.responseFromPay.listen((data) {
      setState(() {
        _code = data.toString();
//        print("支付回调======:" +
//            data.errStr +
//            ",errCode=" +
//            data.errCode.toString());
      });
    });
    flulmAuth.isLemaPayInstalled().then((value) => setState(() => _isInstalled = value));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('授权支付Demo'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(24.0),
        child: Column(
          children: [
            Row(children: [Text("乐马支付App"), Spacer(), Text(_isInstalled ? "已安装" : "未安装")]),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                ElevatedButton(onPressed: () => sendAuth(context), child: Text("授权")),
                ElevatedButton(onPressed: () => sendPay(context), child: Text("支付")),
              ],
            ),
            Text('callback code= $_code\n'),
          ],
        ),
      ),
    );
  }

  void sendAuth(BuildContext context) async {
    print("开始授权=》");
    flulmAuth.sendAuth(
      mContext: context,
      openId: _appId,
      supportScan: true,
      scope: "login",
      isTest: 2,
    );
  }

  void sendPay(BuildContext context) async {
    flulmAuth.sendPay(
      mContext: context,
      openId: _appId,
      supportScan: true,
      signData:
          'eyJhcHBfaWQiOiIxOTAzMDQxOTUyMjY3NzEyNjk0IiwidGltZXN0YW1wIjoxNjA4MDI1MDkxLCJub25jZV9zdHIiOiJiR0lWWGhqbktvZjJMcnpTSGJReHdqbG95REJBSjRSNiIsIm9yZGVyX2lkIjoiMjAxMjE1MTczODExOTY4Mzg1MyIsInVpZCI6IjQyZWIyZTgzZjg1NTI2ZTM2ODVjMGFiMjhlZTY1N2ZmIiwicmlkIjoiIiwic2lnbiI6IjM4NTUxQjk3MzVBQ0NFREE5MDEzNkI1M0Q0QjBCNzU1In0=',
      isTest: 2,
    );
  }
}
2
likes
65
pub points
0%
popularity

Publisher

unverified uploader

The version of the flutter SDK licensed by lemapay is currently only available for the Android system, to be added to the iOS system call.

Homepage

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

convert, crypto, dio, encrypt, flutter, logger, url_launcher, uuid, webview_flutter

More

Packages that depend on flulm_auth