flutter_account_kit 0.5.2

  • README.md
  • Example
  • Installing
  • Versions
  • 90


pub package Build Status Coverage Status A Flutter plugin for allowing users to authenticate with the native Android & iOS AccountKit SDKs

How do I use it?

For complete API documentation, just see the source code.

import 'package:flutter_account_kit/flutter_account_kit.dart';

AccountKit akt = new AccountKit();
LoginResult result = await akt.logInWithPhone();

switch (result.status) {
  case LoginStatus.loggedIn:
  case LoginStatus.cancelledByUser:
  case LoginStatus.error:


To get things up and running, you'll have to declare a pubspec dependency in your Flutter project. Also some minimal Android & iOS specific configuration must be done, otherwise your app will crash.

On your Flutter project

See the installation instructions on pub.


Find out your Facebook App ID and AccountKit Client Token from Facebook App's dashboard in the Facebook developer console.

1. In **\/android/app/src/main/res/values/strings.xml**
  <string name="fb_app_id">YOUR_FACEBOOK_APP_ID</string>
  <string name="ak_client_token">YOUR_CLIENT_TOKEN</string>
  1. In /android/app/src/main/AndroidManifest.xml

          android:value="@string/fb_app_id" />
          android:value="@string/app_name" />
          android:value="@string/ak_client_token" />

This is the minimal required configuration. Take a look to the Account Kit documentation for Android for a more detailed guide.

(Optional) Exclude backup for Access Tokens on Android >= 6.0

As per this documentation, Account Kit does not support automated backup (introduced in Android 6.0). The following steps will exclude automated backup

  1. Create a file /android/app/src/main/res/xml/backup_config.xml that contains the following:
  <?xml version="1.0" encoding="utf-8"?>
    <exclude domain="sharedpref" path="com.facebook.accountkit.AccessTokenManager.SharedPreferences.xml"/>
  1. In your AndroidManifest.xml add the following to exclude backup of Account Kit's Access Token.
    //other configurations here
    android:fullBackupContent="@xml/backup_config" // add this line

Add your Facebook credentials to your project's Info.plist file

  <plist version="1.0">

This is the minimal required configuration. Take a look to the Account Kit documentation for iOS for a more detailed guide.



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

final theme = AccountKitTheme(
    // Background
    backgroundColor: Color.fromARGB(0.1, 0, 120, 0,),
    backgroundImage: 'background.png',
    // Button
    buttonBackgroundColor: Color.fromARGB(1.0, 0, 153, 0),
    buttonBorderColor: Color.fromARGB(1, 0, 255, 0),
    buttonTextColor: Color.fromARGB(1, 0, 255, 0),
    // Button disabled
    buttonDisabledBackgroundColor: Color.fromARGB(0.5, 100, 153, 0),
    buttonDisabledBorderColor: Color.fromARGB(0.5, 100, 153, 0),
    buttonDisabledTextColor: Color.fromARGB(0.5, 100, 153, 0),
    // Header
    headerBackgroundColor: Color.fromARGB( 1.0, 0, 153, 0),
    headerButtonTextColor: Color.fromARGB(0.5, 0, 153, 0),
    headerTextColor: Color.fromARGB(1, 0, 255, 0),
    // Input
    inputBackgroundColor: Color.fromARGB(1, 0, 255, 0),
    inputBorderColor: Color.hex('#ccc'),
    inputTextColor: Color(0xFFb74093),
    // Others
    iconColor: Color(0xFFFFFFFF),
    textColor: Color(0xFFb74093),
    titleColor: Color(0xFFb74093),
    // Header
    statusBarStyle: StatusBarStyle.lightStyle, // or StatusBarStyle.defaultStyle
AccountKit akt = new AccountKit();
Config cfg = Config()
             ..theme = theme;

To see the statusBarStyle reflected you must set the UIViewControllerBasedStatusBarAppearance property to true on your app's Info.plist file. You can do it from XCode <img width="507" alt="screen shot 2016-08-02 at 11 44 07 am" src="https://cloud.githubusercontent.com/assets/1652196/17332979/0fa632b2-58a7-11e6-9aa3-a669ae44f2e6.png">



Check this commit to see how it's done in our sample app

  1. In your application styles.xml file (usually located in /android/app/src/main/res/values folder) create a Theme with the following schema
<style name="LoginThemeYellow" parent="Theme.AccountKit">
    <item name="com_accountkit_primary_color">#f4bf56</item>
    <item name="com_accountkit_primary_text_color">@android:color/white</item>
    <item name="com_accountkit_secondary_text_color">#44566b</item>
    <item name="com_accountkit_status_bar_color">#ed9d00</item>

    <item name="com_accountkit_input_accent_color">?attr/com_accountkit_primary_color</item>
    <item name="com_accountkit_input_border_color">?attr/com_accountkit_primary_color</item>

See the full set of customizable fields here

  1. In your app AndroidManifest.xml file (usually under /android/app/src/main folder) set that Theme to the AccountKitActivity
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" <-- Add this line

    <!-- Set the AccountKitActivity theme -->
      android:theme="@style/LoginThemeYellow" />



"A system issue occured, Please try again" when sending SMS

A. Check your FacebookAppID and AccountKitClientToken on iOS Info.plist and Android strings.xml are correct

B. If you have enabled the client access token flow in fb account kit dashboard, then responseType should be set to code when calling configure

// Configures the SDK with some options
import 'package:flutter_account_kit/flutter_account_kit.dart';

AccountKit akt = new AccountKit();
Config cfg = Config()
             ..responseType = ResponseType.code;


This project was inspired by flutter_facebook_login and react-native-facebook-account-kit


  • Rename method channel


  • Fix formatting


  • Initial release.


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

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

class MyApp extends StatefulWidget {
  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> {
  FlutterAccountKit akt = FlutterAccountKit();
  int _state = 0;
  bool _isInitialized = false;

  void initState() {

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initAccountkit() async {
    print('Init account kit called');
    bool initialized = false;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      final theme = AccountKitTheme(
          headerBackgroundColor: Colors.green, backgroundColor: Colors.blue);
      await akt.configure(Config()
        ..facebookNotificationsEnabled = true
        ..receiveSMS = true
        ..readPhoneStateEnabled = true
        ..theme = theme
        ..defaultCountry = "NG");
      initialized = true;
    } on PlatformException {
      print('Failed to initialize account kit');

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;
    setState(() {
      _isInitialized = initialized;
      print("isInitialied $_isInitialized");

  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        body: new Center(
          child: RaisedButton(
            padding: EdgeInsets.all(0.0),
            color: _state == 2 ? Colors.green : Colors.blue,
            child: buildButtonChild(),
            onPressed: _isInitialized ? this.login : null,

  Widget buildButtonChild() {
    if (_state == 0) {
      return Text(
        style: TextStyle(color: Colors.white, fontSize: 16.0),
    } else if (_state == 1) {
      return SizedBox(
          height: 24.0,
          width: 24.0,
          child: CircularProgressIndicator(
            value: null,
            valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
    } else {
      return Icon(Icons.check, color: Colors.white);

  Future<void> login() async {
    if (_state == 1) {
    setState(() {
      _state = 1;
    final result = await akt.logInWithPhone();
    if (result.status == LoginStatus.cancelledByUser) {
      print('Login cancelled by user');
      setState(() {
        _state = 0;
    } else if (result.status == LoginStatus.error) {
      print('Login error');
      setState(() {
        _state = 0;
    } else {
      print('Login success');
      setState(() {
        _state = 2;

Use this package as a library

1. Depend on it

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

  flutter_account_kit: ^0.5.2

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_account_kit/flutter_account_kit.dart';
Version Uploaded Documentation Archive
0.5.2 Jul 22, 2018 Go to the documentation of flutter_account_kit 0.5.2 Download flutter_account_kit 0.5.2 archive
0.5.1 Jul 22, 2018 Go to the documentation of flutter_account_kit 0.5.1 Download flutter_account_kit 0.5.1 archive
0.5.0 Jul 21, 2018 Go to the documentation of flutter_account_kit 0.5.0 Download flutter_account_kit 0.5.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4
  • Flutter: 0.9.5


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.

Format lib/src/config.dart.

Run flutter format to format lib/src/config.dart.

Format lib/src/utils.dart.

Run flutter format to format lib/src/utils.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.58.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
mockito ^2.2.3