flutter_uae_pass 0.0.2 copy "flutter_uae_pass: ^0.0.2" to clipboard
flutter_uae_pass: ^0.0.2 copied to clipboard

A UAE Pass plugin for Flutter for iOS and Android only. This is an unofficial version.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_uae_pass/uae_pass.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? authCode;
  String? accessToken;
  ProfileData? profileData;

  final _uaePass = UaePass();

  @override
  void initState() {
    super.initState();
    _uaePass.setUpEnvironment(
      clientId: "<clientId>",
      clientSecret: "<clientSecret>",
      urlScheme: "myappscheme",
      redirectUri: "<redirectUri>",
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('UAE Pass'),
          centerTitle: true,
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MaterialButton(
                onPressed: () => login(),
                child: const Text('Sign in with UAE Pass'),
              ),
              const SizedBox(height: 100),
              if (authCode != null)
                ListTile(
                  title: const Text('Auth Code'),
                  subtitle: Text('${authCode?.substring(0, 6)}............'),
                ),
              if (accessToken != null)
                ListTile(
                  title: const Text('Access Token'),
                  subtitle: Text('${accessToken?.substring(0, 6)}............'),
                ),
              if (profileData != null)
                Column(
                  children: [
                    ListTile(
                      title: const Text('Full Name EN'),
                      subtitle: Text(profileData?.fullnameEN ?? ""),
                    ),
                    ListTile(
                      title: const Text('Mobile'),
                      subtitle: Text(profileData?.mobile ?? ""),
                    ),
                    ListTile(
                      title: const Text('Nationality EN'),
                      subtitle: Text(profileData?.nationalityEN ?? ""),
                    ),
                  ],
                ),
            ],
          ),
        ),
      ),
    );
  }

  Future<void> login() async {
    authCode = null;
    accessToken = null;
    profileData = null;
    setState(() {});
    try {
      authCode = await _uaePass.signIn();
      accessToken = await _uaePass.getAccessToken(authCode ?? "");
      profileData = await _uaePass.getProfile(accessToken ?? "");

      setState(() {});
    } catch (e) {
      if (kDebugMode) {
        print(e.toString());
      }
    }
    setState(() {});
  }
}
6
likes
0
pub points
69%
popularity

Publisher

verified publishermohamed-abdo.com

A UAE Pass plugin for Flutter for iOS and Android only. This is an unofficial version.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_uae_pass