fireauth_ui 0.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new84

fireauth_ui

Build Status pub package

Allows you to quickly connect common Firebase auth with basic UI.

Support Sign-in Providers List

Sign in methodSupport
Email
Phone
Google
Play Games
Facebook
Twitter
Github

Support language

  • English

  • Chinses (Tranditional)

Email sign in demo screen

email_demo_video

Installation

Add to your pubspec dependencies:

fireauth_ui: ^0.0.1

Please follow below guides to setup.

  1. Open Firebase Console ( https://console.firebase.google.com/ )

  2. Create your project

  3. Add Firebase to your iOS app

    • Open "ios/Runner.xcworkspace"

    • Drag that "GoogleService-Info.plist" into the Runner directory then dialog will show up and ask you to select the targets, select the Runner target

  4. Add Firebase to your Android app

    • Place "google-services.json" in "android/app" folder

    • If your project required "Google Sign in", please ensure config "Debug signing certificate SHA-1" also.

      You can run this command to get SHA-1 hash from android debug keystore Noted: debug keystore password is "android"

        keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
      
    • Open "android/build.gradle"

        buildscript {
            dependencies {
                // Add this line
                classpath 'com.google.gms:google-services:3.2.1'
            }
        }
      
    • Open "android/app/build.gradle"

        dependencies {
            // Add this line
            compile 'com.google.firebase:firebase-core:16.0.0'
        }
        ...
        // Add to the bottom of the file
        apply plugin: 'com.google.gms.google-services'
      
      
  5. Go to "Authentication" Section

  6. Select Sign-in method

  7. Enable "Sign-in providers" which you need, please see support list

    • Email Sign in

      • Just enable it
    • Google Sign-in

      • Add the CFBundleURLTypes attributes below into the "/ios/Runner/Info.plist" file.
        <key>CFBundleURLTypes</key>
        <array>
            <dict>
                <key>CFBundleTypeRole</key>
                <string>Editor</string>
                <key>CFBundleURLSchemes</key>
                <array>
                    <!-- TODO Replace this value: -->
                    <!-- Copied from GoogleServices-Info.plist key REVERSE_CLIENT_ID -->
                    <string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
                </array>
            </dict>
        </array>
      
    • Facebook Sign-in

      • Open https://developers.facebook.com/

      • Click My App then select Add New App

      • In Facebook Login section, click Setup

      • Follow instruction in facebook developer page to setup iOS and Android

      Take care when paste facebook's CFBundleURLTypes into plist <br/>Don't overwrite Google Sign-in CFBundleURLTypes

      • Finally, remember copy OAuth redirect URI to Firebase's facebook sign-in

        Paste URI in Facebook Login > Settings > Valid OAuth Refirect URIs

Getting Started

Add the following import to your Dart code:

import 'package:fireauth_ui/fireauth_ui.dart';

You can install packages from the command line:

with Flutter:

flutter packages get

Sample code show you how to present sign in page

Navigator.push(
      context,
      new MaterialPageRoute(
          builder: (context) => new FireAuthUISignInPage(
                providers: [
                    FireAuthUIProvider.Email,
                    FireAuthUIProvider.Facebook,
                    FireAuthUIProvider.Google,
                ],
              )),
    );

Dependencies

flutter_facebook_login

firebase_auth

google_sign_in

Credit

  • frmunozr10
    • Spanish and Catalan language support enhancement

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

[0.0.3] - 28 June, 2018

  • Spanish and Catalan language support enhancement

[0.0.2] - 19 June, 2018

  • auto select next textfield if user press "done" button on keyboard

[0.0.1] - 18 June, 2018

  • initial alpha release

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:fireauth_ui/fireauth_ui.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:firebase_auth/firebase_auth.dart';

void main() => runApp(new MaterialApp(
      localizationsDelegates: [
        // ... app-specific localization delegate[s] here
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        FireAuthUILocalizationsDelegate.delegate,
      ],
      supportedLocales: [
        const Locale('en', 'US'), // English
        const Locale('jp', 'JP'), // Hebrew
        const Locale('zh_HK', 'HK'), // Hebrew
        // ... other locales the app supports
      ],
      home: new MyApp(),
      localeResolutionCallback:
          (Locale locale, Iterable<Locale> supportedLocales) {
        return locale;
      },
    ));

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

class _MyAppState extends State<MyApp> {
  bool emailEnable = true;
  bool facebookEnable = true;
  bool googleEnable = true;
  FirebaseUser user;
  Stream<FirebaseUser> _userSteam;
  StreamSubscription _onAuthStateChangedSubscription;

  @override
  initState() {
    super.initState();
    _userSteam = FirebaseAuth.instance.onAuthStateChanged;
    _onAuthStateChangedSubscription =
        _userSteam.listen(onAuthStateChanged);
  }

  void onAuthStateChanged(FirebaseUser user) {
    setState(() {
      this.user = user;
    });
  }

  void dispose() {
    super.dispose();
    _onAuthStateChangedSubscription.cancel();
  }

  Widget _buildUserInfo() {
    if (user == null) {
      return new Container();
    }
    return new Card(
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          children: <Widget>[
            new Center(child: new Text('User Info:'),),
            new Row(children: <Widget>[
              user.photoUrl == null
                  ? new Container()
                  : new Image.network(user.photoUrl),
              new Expanded(
                child: new Column(
                  children: <Widget>[
                    new Text("Display Name"),
                    user.displayName == null
                        ? new Container()
                        : new Text(user.displayName)
                  ],
                ),
              ),
            ])
          ],
        ),
      ),
    );
  }

  void _showSignInPage() {
    List<FireAuthUIProvider> providers = [];
    if (emailEnable) {
      providers.add(FireAuthUIProvider.Email);
    }

    if (facebookEnable) {
      providers.add(FireAuthUIProvider.Facebook);
    }

    if (googleEnable) {
      providers.add(FireAuthUIProvider.Google);
    }
    Navigator.push(
      context,
      new MaterialPageRoute(
          builder: (context) => new FireAuthUISignInPage(
                providers: providers,
              )),
    ).then((_) {
      setState(() {

      });
    });

  }

  Future _signOut() async {
    setState(() {
      user = null;
    });
    await FirebaseAuth.instance.signOut();
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Fire Auth UI Demo'),
      ),
      body: new ListView(
        padding: EdgeInsets.all(24.0),
        children: <Widget>[
          _buildUserInfo(),
          new SizedBox(
            height: 24.0,
          ),
          new Row(
            children: <Widget>[
              new Expanded(child: new Text("Provider")),
              new Text("Enable"),
            ],
          ),
          new Row(
            children: <Widget>[
              new Expanded(child: new Text("Email")),
              new Checkbox(
                  value: emailEnable,
                  onChanged: (bool value) {
                    setState(() {
                      emailEnable = value;
                    });
                  })
            ],
          ),
          new Row(
            children: <Widget>[
              new Expanded(child: new Text("Google")),
              new Checkbox(
                  value: googleEnable,
                  onChanged: (bool value) {
                    setState(() {
                      googleEnable = value;
                    });
                  })
            ],
          ),
          new Row(
            children: <Widget>[
              new Expanded(child: new Text("Facebook")),
              new Checkbox(
                  value: facebookEnable,
                  onChanged: (bool value) {
                    setState(() {
                      facebookEnable = value;
                    });
                  })
            ],
          ),
          new Center(
            child: new RaisedButton(
              onPressed: user == null ? _showSignInPage : _signOut,
              child: new Text(user == null ? "Sign in" : "Sign out"),
            ),
          )
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  fireauth_ui: ^0.0.3

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:fireauth_ui/fireauth_ui.dart';
  
Version Uploaded Documentation Archive
0.0.3 Jun 28, 2018 Go to the documentation of fireauth_ui 0.0.3 Download fireauth_ui 0.0.3 archive
0.0.2 Jun 19, 2018 Go to the documentation of fireauth_ui 0.0.2 Download fireauth_ui 0.0.2 archive
0.0.1 Jun 18, 2018 Go to the documentation of fireauth_ui 0.0.1 Download fireauth_ui 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
77
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
84
Learn more about scoring.

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

  • Dart: 2.0.0-dev.66.0
  • pana: 0.11.7
  • Flutter: 0.5.5

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Format lib/dialog.dart.

Run flutter format to format lib/dialog.dart.

Format lib/email_button.dart.

Run flutter format to format lib/email_button.dart.

Fix additional 14 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/email_input_page.dart (Run flutter format to format lib/email_input_page.dart.)
  • lib/email_sign_in_page.dart (Run flutter format to format lib/email_sign_in_page.dart.)
  • lib/email_sign_up_page.dart (Run flutter format to format lib/email_sign_up_page.dart.)
  • lib/facebook_button.dart (Run flutter format to format lib/facebook_button.dart.)
  • lib/fireauth_ui.dart (Run flutter format to format lib/fireauth_ui.dart.)
  • lib/google_button.dart (Run flutter format to format lib/google_button.dart.)
  • lib/l10n/messages_all.dart (Run flutter format to format lib/l10n/messages_all.dart.)
  • lib/l10n/messages_ca.dart (Run flutter format to format lib/l10n/messages_ca.dart.)
  • lib/l10n/messages_es.dart (Run flutter format to format lib/l10n/messages_es.dart.)
  • lib/l10n/messages_messages.dart (Run flutter format to format lib/l10n/messages_messages.dart.)
  • lib/l10n/messages_zh.dart (Run flutter format to format lib/l10n/messages_zh.dart.)
  • lib/l10n/messages_zh_HK.dart (Run flutter format to format lib/l10n/messages_zh_HK.dart.)
  • lib/localizations.dart (Run flutter format to format lib/localizations.dart.)
  • lib/password_field.dart (Run flutter format to format lib/password_field.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <2.0.0
firebase_auth ^0.5.11 0.5.12
flutter 0.0.0
flutter_facebook_login ^1.1.1 1.1.1
flutter_localizations 0.0.0
google_sign_in ^3.0.4 3.0.4
Transitive dependencies
collection 1.14.6 1.14.10
intl 0.15.6
meta 1.1.5
path 1.6.0 1.6.1
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7
Dev dependencies
flutter_test
intl_translation ^0.16.6