fasekyc_flutter 0.0.6+4 copy "fasekyc_flutter: ^0.0.6+4" to clipboard
fasekyc_flutter: ^0.0.6+4 copied to clipboard

FaS eKYC Flutter Package

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:fasekyc_flutter/fasekyc_flutter.dart';

Future main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(new MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      home: NewHomePage(),
    );
  }
}

class NewHomePage extends StatefulWidget {
  @override
  _NewHomePageState createState() => _NewHomePageState();
}

class _NewHomePageState extends State<NewHomePage> {
  int? selectedRadio;
  String clientId = "605d435e86e4c700f9dd33ac";
  String clientSecret = "88b204f9-3ab0-44ba-983b-a2b2d4cb6fb1";
  String grantType = "authorization_code";
  String returnUrl = "my.test.app://oauth2redirect";
  List<String> scope = ["email", "openid"];
  String customUriScheme = "my.test.app";
  String authUrl = "https://app-dev.fasekyc.com";
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Color(0xFF2168F6),
        elevation: 0,
      ),
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        color: Color(0xFF2168F6),
        child: Column(
          children: [
            Expanded(
              flex: 0,
              child: InkWell(
                onTap: () {},
                child: Container(
                  // color: Colors.red,
                  margin: EdgeInsets.only(top: 0),
                  width: 110,
                  height: 100,
                  child: Image.asset('assets/images/ekyc_white_logo.png'),
                ),
              ),
            ),
            Expanded(flex: 2, child: _buildWelcomeText()),
            Expanded(flex: 0, child: _buildLoginButton())
          ],
        ),
      ),
    );
  }

  Widget _buildWelcomeText() {
    return Container(
        // color: Colors.yellow,
        child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text(
          "សូមស្វាគមន៍មកកាន់ FaS eKYC",
          style: TextStyle(
              color: Colors.white,
              fontSize: 22,
              fontWeight: FontWeight.bold,
              fontFamily: 'khFont'),
        ),
        SizedBox(
          height: 8.0,
        ),
        Text(
          "ចាប់ផ្តើមការផ្ទៀងផ្ទាត់ដោយចុចបូតុងខាងក្រោម",
          style: TextStyle(
              color: Colors.white, fontSize: 14, fontFamily: 'khFont'),
        ),
      ],
    ));
  }

  Widget _buildLoginButton() {
    return Padding(
      padding: const EdgeInsets.only(left: 24.0, right: 24.0, bottom: 50),
      child: FaSeKYCAuthButton(
        personId: "611dd2317fd9e1988f7ba0eb",
        clientId: clientId,
        clientSecret: clientSecret,
        redirectUri: returnUrl,
        customUriScheme: customUriScheme,
        scopes: scope,
        child: Padding(
          padding: const EdgeInsets.symmetric(vertical: 4.0),
          child: Row(
            children: [
              Container(
                height: 50,
                width: 50,
                child: Center(
                    child: Image.asset('assets/images/ekyc_white_logo.png')),
              ),
              SizedBox(
                width: 8.0,
              ),
              Container(
                height: 30,
                child: VerticalDivider(
                  color: Colors.white,
                ),
              ),
              Expanded(
                flex: 2,
                child: Center(
                  child: Text(
                    "ផ្ទៀងផ្ទាត់",
                    style: TextStyle(
                        color: Colors.white,
                        fontFamily: 'khFont',
                        fontSize: 16.0),
                  ),
                ),
              ),
            ],
          ),
        ),
        onSuccess: (bool isSuccess) {
          print(isSuccess);
          // showAlertDialog(context, "Hello: " + personInfoModel.toString());
        },
        onUserCancel: (String message) {
          showAlertDialog(context, message);
        },
      ),
    );
  }

  showAlertDialog(BuildContext context, String message) {
    // set up the button
    Widget okButton = TextButton(
      child: Text("OK"),
      onPressed: () {
        Navigator.of(context).pop();
      },
    );

    // set up the AlertDialog
    AlertDialog alert = AlertDialog(
      title: Text("ព័ត៍មាន"),
      content: Text(message),
      actions: [
        okButton,
      ],
    );

    // show the dialog
    showDialog(
      context: context,
      builder: (BuildContext context) {
        return alert;
      },
    );
  }
}
0
likes
90
pub points
0%
popularity

Publisher

unverified uploader

FaS eKYC Flutter Package

Homepage

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, graphql, http, oauth2_client

More

Packages that depend on fasekyc_flutter