fb_accountkit_flutter 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

Welcome to Facebook Account Kit Flutter Version! #

What's that? #

As you all know, Facebook Account Kit - powered by Facebook - lets you quickly register for and login to your app by using just user's phone number. It's reliable and easy to integrate. Now it's is available in Flutter.

Let's prepare some your own Facebook Developer information !!! #

Note: If your project just provide for only 1 platform. You can skip the other part.

*** For Android Configuration:

  • Open your project, create strings.xml file at this path: \android\app\src\main\res
  • Add 2 variables like below:
<?xml version="1.0" encoding="utf-8"?>  
<resources>  
    <string name="FACEBOOK_APP_ID" translatable="false">[YOUR_FACEBOOK_APP_ID]</string>  
    <string name="ACCOUNT_KIT_CLIENT_TOKEN" translatable="false">[ACCOUNT_KIT_CLIENT_TOKEN]</string>  
</resources>

About the Facebook App ID and Account Kit Client Token, please keep reading

  • Set up your AndroidManifest.xml in /android/app/src/main. Full code here.

*** For iOS Configuration:

  • Open ios\Runner\Info.plist by right click -> open by source code
  • Copy and paste this inside the space between <dict></dict> tag.
	<key>FacebookAppID</key>
    <string>[YOUR_FACEBOOK_APP_ID]</string>
    <key>AccountKitClientToken</key>
    <string>[ACCOUNT_KIT_CLIENT_TOKEN]</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>ak[YOUR_FACEBOOK_APP_ID]</string>
            </array>
        </dict>
    </array>

About Facebook App Id and Account Kit Client Token:

YOUR_FACEBOOK_APP_ID: you can get it in picture below and simply press to copy YOUR_FACEBOOK_APP_ID ACCOUNT_KIT_CLIENT_TOKEN: ACCOUNT_KIT_CLIENT_TOKEN

... It's done for configuration !! Let's go back to Flutter main.dart

How to use? #

It's very easy !!!

1. Add dependency to your pubspec.yaml file: #

dependencies:  
    fb_accountkit_flutter: ^0.0.2

And do not forget to call flutter get to get the dependency in pub.dev

2. Import to your code: #

import 'package:fb_accountkit_flutter/fb_accountkit_flutter.dart';

3. Call open AccountKit whenever you want: #

Result result = await FbAccountkitFlutter.startAuthentication()

Example Function #

import 'dart:async';  
import 'package:flutter/services.dart';  
import 'package:fb_accountkit_flutter/fb_accountkit_flutter.dart';

Future<void> openFacebookActivity() async {  
  Result result;  
  
  try {  
    FbAccountkitFlutter.defaultCountryCode = "[YOUR DEFAULT COUNTRY CODE]"; // Ex:  US, AL etc.  
	// Find more here : https://developers.facebook.com/docs/accountkit/countrycodes/  
	FbAccountkitFlutter.codeIso = "[YOUR ISO CODE]"; // Ex: 93, 355 etc.  
	// Find Dialing Code here : https://developers.facebook.com/docs/accountkit/countrycodes/  
	FbAccountkitFlutter.countryCode = "[YOUR COUNTRY CODE]";  
    // Find A 3 in here : http://kirste.userpage.fu-berlin.de/diverse/doc/ISO_3166.html  
	
	// Optional  
	FbAccountkitFlutter.phone = "[INITIAL PHONE]";  
	
	// Request open accountkit  
	result = await FbAccountkitFlutter.startAuthentication();  
  
  } on PlatformException catch(e) {  
    print(e);  
    result = null;  
  }  
  
}

You can read the full code in the example package also.

Happy Coding ! #

0.0.1 #

Initial release.

0.0.2 #

Ready for usage

1.0.0 #

Optimize, Clean to high. Update Document.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:fb_accountkit_flutter/fb_accountkit_flutter.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Result _loginResult = Result();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Account Kit Flutter example app'),
          backgroundColor: Colors.redAccent,
        ),
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.max,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              RaisedButton(
                  onPressed: () {
                    openFacebookActivity();
                  },
                  child: Text("Open Account Kit SMS Authenation")),
              Text('Result:  ${_loginResult.message == null ? "Ready to Process" : _loginResult.message}\n'),
              _getOptionalInformation()
            ],
          ),
        ),
      ),
    );
  }

  Future<void> openFacebookActivity() async {
    Result result;

    try {

      FbAccountkitFlutter.defaultCountryCode = "[YOUR DEFAULT COUNTRY CODE]"; // Ex:  US, AL etc.
      // Find more here : https://developers.facebook.com/docs/accountkit/countrycodes/

      FbAccountkitFlutter.codeIso = "[YOUR ISO CODE]"; // Ex: 93, 355 etc.
      // Find Dialing Code here : https://developers.facebook.com/docs/accountkit/countrycodes/

      FbAccountkitFlutter.countryCode = "[YOUR COUNTRY CODE]";
      // Find A 3 in here : http://kirste.userpage.fu-berlin.de/diverse/doc/ISO_3166.html

      // Optional
      FbAccountkitFlutter.phone = "[INITIAL PHONE]";

      // Request open accountkit
      result = await FbAccountkitFlutter.startAuthentication();

    } on PlatformException catch(e) {
      print(e);
      result = null;
    }

    setState(() {
      _loginResult = result;
    });
  }

  Widget _getOptionalInformation() {
    var phone = _loginResult.phone == null ? "Phone Null" : _loginResult.phone;
    var email = _loginResult.email == null ? "Email Null" : _loginResult.email;
    var userId = _loginResult.userId == null ? "User Id Null" : _loginResult.userId;
    if (_loginResult.status == FbAccountkitFlutter.SUCCEED) {
      return Text("Optional Info: \n Phone -> $phone \n Email -> $email \n UserId -> $userId");
    }
    return Container();
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  fb_accountkit_flutter: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:fb_accountkit_flutter/fb_accountkit_flutter.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
41
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on May 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health issues and suggestions

Document public APIs. (-1 points)

18 out of 18 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/fb_accountkit_flutter.dart.

Run flutter format to format lib/fb_accountkit_flutter.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test