apexid 0.0.2
apexid: ^0.0.2 copied to clipboard
ApexID Login plugin.
example/lib/main.dart
import 'package:apexid/router.dart';
import 'package:apexid_example/router.dart';
import 'package:apexid_example/widget_load.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:apexid/apexid.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetLoadMixin {
@override
void initState() {
ApexId.shared.initialize(developerKey: "286169943627329:hfttUnXvZ");
super.initState();
}
@override
void onLoad(BuildContext context) async {}
@override
Widget build(BuildContext context) {
return MaterialApp(
onGenerateRoute: Router.generateRoute,
initialRoute: Router.mainRoute,
title: 'ApexID Example',
);
}
}
class MainScreen extends StatefulWidget {
@override
_MainScreenState createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("ApexId Example"),
),
body: Column(
children: [
// Text("Login AccessKey: " + ApexId.shared.getAccessKey()),
RaisedButton(
child: Text("Press to logout from apexId"),
onPressed: () {
ApexId.shared.logoutFromApexId();
setState(() {});
},
),
ApexId.shared.apexSettingButton(
child: RaisedButton(
onPressed: () {
Router.namedNavigateTo(context, Router.apexIdSettings);
},
child: Text("ApexID Settings"),
),
onBackPressed: () {
Router.namedNavigateTo(context, Router.mainRoute,
replacement: true);
}),
ApexId.shared.apexLoginButton(
onLoginMethod: (accessKey, cntxt) {
/// You should navigate user to your page.
Router.namedNavigateTo(cntxt, Router.mainRoute);
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: RaisedButton(
onPressed: () {
Router.namedNavigateTo(context, Router.apexId);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40)),
color: Colors.white,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Image.asset(
"assets/img/logo.png",
package: "apexid",
width: 20,
height: 20,
),
Text(
"Press to login with ApexId",
style: TextStyle(color: Colors.blue),
),
],
),
),
),
cntxt: context,
),
],
),
);
}
}