faui is an authentication UI for Flutter. 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. Also it supports silent sign in.
To test the library use demo project.
apiKey: "AIzaSyA3hshWKqeogfYiklVCCtDaWJW8TfgWgB4"
Then you will want to create your project:
- Sign in to firebase console https://console.firebase.google.com/
- Add, configure and open project
- In the project open tab "Authentication" and then tab "Sign-in Method"
- Click "Email/Password", set "Enable" and click "Save"
- Select "Project Settings" (gear icon)
- Copy your "Web API Key"
- Update pubspec.yaml to make sure your project references necessary packages:
dependencies:
...
faui: <latest version>
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: "...",
);
}
Import:
import 'package:faui/faui.dart';
Get user email:
faui.User.email
Sign out:
faui.signOut()
Silent sign-in:
// Before runApp:
WidgetsFlutterBinding.ensureInitialized();
await faui.trySignInSilently(firebaseApiKey: '...');
...
// After sign in with dialog:
faui.saveUserLocallyForSilentSignIn();