Skip to content
flutter-auth-ui is an authentication library for flutter web applications. It uses Firebase auth as security as a service (SECaaS) provider. It implements UI to register user, validate email, sign in, sign out, restore password.
Dart
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib test for token validation Aug 14, 2019
test
.gitignore
README.md
pubspec.yaml

README.md

flutter-auth-ui (faui)

faui is an authentication library for flutter web applications. It registers users with email and password using Firebase security as a service ( SECaaS ). The library provides UI to register user, validate email, sign in, sign out and restore password.

The library works with flutter for web tech preview, with intent to switch to production, and to start supporting iOS and Android, as soon as flutter for web gets released.

Demo

Explore UX here.

Source code: flutter-auth-ui-demo.

Getting Started

Create Project in Firebase

To test the library use demo project.

apiKey: "AIzaSyA3hshWKqeogfYiklVCCtDaWJW8TfgWgB4"

Then you will want to create your project:

  1. Sign in to firebase console https://console.firebase.google.com/
  2. Add, configure and open project
  3. In the project open tab "Authentication" and then tab "Sign-in Method"
  4. Click "Email/Password", set "Enable" and click "Save"
  5. Select "Project Settings" (gear icon)
  6. Copy your "Web API Key"

Set Dependency

While flitter_web is not published in pub, the packages that depend on it, cannot be published too. So, you need to setup submodule:

  1. Run:
git submodule add https://github.com/polina-c/flutter-auth-ui ./lib/external/flutter-auth-ui
  1. Update pubspec.yaml to make sure your project references necessary packages:
dependencies:
  ...
  http: ^0.12.0+2
  uuid: 2.0.1

dev_dependencies:
  ...
  test: any

Update Code

In the beginning of the method build of the widget that requires authentication (it should be stateful), add the code:

if (faui.User == null) {
  return faui.BuildAuthScreen(
    onExit: this.setState((){...}),
    firebaseApiKey: "...",
  );
}

Packages to import:

import 'package:<your app name>/external/flutter-auth-ui/lib/faui.dart';
import 'package:<your app name>/external/flutter-auth-ui/lib/faui_model.dart';

Get user email:

faui.User.email

Sign out:

faui.SignOut()

Silent sign-in:


// Before start:
FauiUser user =
      await faui.TrySignInSilently(firebaseApiKey: XfConfig.FirebaseApiKey);
...

// After sign in with dialog:
faui.SaveUserLocallyForSilentSignIn();

Run Tests

flutter pub run test

You can’t perform that action at this time.