auth_ui_flutter 2.0.0-karbon-patch.1 auth_ui_flutter: ^2.0.0-karbon-patch.1 copied to clipboard
A flutter plug-in for the native AuthUI library (Android and iOS).
import 'dart:async';
import 'package:auth_ui_flutter/terra_auth_ui.dart';
import 'package:auth_ui_flutter/builder/login_ui_config_builder.dart';
import 'package:flutter/material.dart';
import 'package:terra_flutter/terra_app.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
static const _appName = "ajaclimatesolutions";
late TerraAuthUI _terraAuthUI;
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
await TerraApp.initTerraApp(appName: _appName);
_terraAuthUI = await TerraAuthUI.getInstance(_appName);
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: SingleChildScrollView(
child: Column(
children: [
ElevatedButton(
onPressed: () async {
try {
var config = LoginUIConfigBuilder()
.withLocalAssetFilename("assets/bitcoin.png")
// .withLocalAssetFilename("ethereum.png")
.withAuthenticationCancellable(true)
//.withAccount("thanh.bm@teko.vn")
.setEnableAutofillOtp(true)
.build();
_terraAuthUI.setLanguageCode("en");
await _terraAuthUI.startLogin(config);
print("[flutter] success");
} catch (e) {
print("[flutter] exception" + e.toString());
}
},
child: const Text("Start Login UI")),
],
),
),
),
);
}
}