fusion_auth 1.0.3 copy "fusion_auth: ^1.0.3" to clipboard
fusion_auth: ^1.0.3 copied to clipboard

This is a plug-in for one click login in the alicloud fusion authentication service. Alibaba cloud is also used in the one click login function

example/lib/main.dart

import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:fusion_auth/fusion_auth.dart';

void main() {
  runApp(const MyApp());
}

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  late FusionAuth _fusionAuthPlugin;

  /// 控制显示屏蔽蒙层
  late bool isCurrentLogin = false;

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

    /// 初始化时添加监听以免接受不到某些回调数据
    _fusionAuthPlugin = FusionAuth(onEvent: (ResponseModel onEvent) async {
      if (kDebugMode) {
        print(">>>>>>>> $onEvent <<<<<<<<");
      }
      setState(() {
        // 唤起授权页面后需要处理点击穿透的问题
        isCurrentLogin = onEvent.errorCode == "400003";
        _platformVersion = onEvent.toJson().toString();
      });
      // EasyLoading.show(status: onEvent['msg'] ?? "", maskType: EasyLoadingMaskType.black);
    });
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    await _fusionAuthPlugin.getVersion();
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('阿里云融合认证插件'),
        ),
        body: SafeArea(
          bottom: true,
          child: Stack(
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  Wrap(
                    children: [
                      ElevatedButton(
                        onPressed: () {
                          FusionAuthConfig authConfig = FusionAuthConfig(
                              token: Platform.isAndroid
                                  ? "eyJhY2Nlc3NLZXlJZCI6IlNUUy5OVTNZVjJUTTdlcGR1ZmRlVlVWUVdmSmR1IiwiYWNjZXNzS2V5U2VjcmV0I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tWFJhN0wvaXNFQVpvblVsc1dPZ1FYMDMzS2Rha2FmZ3BRRVM5ckZxNlRWdGRJWVJaU2w2N3l2QVBEZlNwc3d4TWJzK3ptWWVpRWxMMEVhSUw1ZDQ5YTBiRVFiNGxjc25jN1pGUHhWNmlwam13VWRXcHNJLzFhd2JIcklzMkc5YktmMGN1T2V1L0JETXNNdDFOWFdqZlhvU3VDZDM1S05pejI0S2RVQ3p5aTl0L1cwYmJIL3I1NURRSXEvYW8vTnd5ZWRzdDNwRkVVaU1uYnJUYnJxYisvQWk3d3JqdGtwb0NIcHRBUnRuRUpKS24wMzdXZzJSZkZwMkdWYktVRG44UGFaWFppV3h6ZmVRWWluNkhDMWk5ZiswQmR6enZ1WlVoRXRnbUxvbSs3ZDhBQXlmS1czWEpEQks1T2hlVGZVenFtOTMxaEZNbUUrYXdNWGU1eWkybUJoZ2wrRVdvYWdBRXhoenlpVFRLRVNDZjZYc2lxUzhCa0lnWDFuNlZNTEZEOURQeElVdnFlNUg1d2VFVzdzZGVQQngycUczSTZ0TWFhQnRBNytOZnJvOFhKdngwVWZWVUxCNkpOd25idXhtRkgrb0RjOUF3bHF1cEtncXArbWFCQ01NYTkyOCtWaXk4cTRDSHpza2RFVDM5ek5OdVRrY2xQUlo0ZStnYVZ0UG0zVTEreElnbWt4eUFBIiwiZXhwaXJlZFRpbWUiOjE3MDI3NDY0NjE0MDl9",
                              pageType: PageType.fullPort,
                              debugMode: true,
                              isDelay: false,
                              logEnable: true,
                              schemeCode: "FA000000004690134613",
                              templateId: SceneType.login,
                              privacyAlertConfig: PrivacyAlertConfig(
                                  privacyAlertIsNeedShow: false));
                          FusionAuth.initSdk(authConfig);
                        },
                        child: const Text("全屏初始化"),
                      ),
                      ElevatedButton(
                        onPressed: () {
                          FusionAuth.login();
                          setState(() {
                            _platformVersion = "99999";
                          });
                        },
                        child: const Text("开始登录"),
                      ),
                    ],
                  ),
                  Expanded(
                      child: Container(
                    margin: const EdgeInsets.all(2),
                    padding: const EdgeInsets.all(5),
                    decoration: BoxDecoration(
                        border: Border.all(width: 1, color: Colors.grey),
                        borderRadius: BorderRadius.circular(10)),
                    child: SelectableText(
                      _platformVersion,
                      style: const TextStyle(fontSize: 18),
                      onSelectionChanged: (selection, cause) {},
                    ),
                  ))
                ],
              ),
              isCurrentLogin
                  ? Positioned(
                      top: 0,
                      right: 0,
                      bottom: 0,
                      left: 0,
                      child: Container(color: Colors.transparent),
                    )
                  : Container(),
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
125
points
48
downloads
screenshot

Publisher

verified publisherki5k.com

Weekly Downloads

This is a plug-in for one click login in the alicloud fusion authentication service. Alibaba cloud is also used in the one click login function

Repository (GitHub)
View/report issues
Contributing

Topics

#aliyun #phone #sms #idcode #fusion

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, flutter_localizations, json_annotation, plugin_platform_interface

More

Packages that depend on fusion_auth