apexid 0.0.3 copy "apexid: ^0.0.3" to clipboard
apexid: ^0.0.3 copied to clipboard

outdated

ApexID Login plugin (created for ApexTeam flutter developers)

example/lib/main.dart

import 'package:apexid_example/router.dart';
import 'package:apexid_example/widget_load.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:apexid/apexid.dart';

void main() {
  debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
  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",
        apexIdTheme: ApexIdTheme.darkTheme);
    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,
          ),
        ],
      ),
    );
  }
}