flutter_firebase_auth_facade

Last updated:

0 purchases

flutter_firebase_auth_facade Image
flutter_firebase_auth_facade Images
Add to Cart

Description:

flutter firebase auth facade

Flutter_Firebase_Auth_Facade #
A package to add Firebase authentication methods to your app
Use this package as a library #
1. Depend on it #
Add this to your package's pubspec.yaml file:
dependencies:
flutter_firebase_auth_facade: latest_version
copied to clipboard
2. Install it #
You can install packages from the command line:
with Flutter:
$ flutter pub get
copied to clipboard
3. Import it #
Now in your Dart code, you can use:
import 'package:flutter_firebase_auth_facade/flutter_firebase_auth_facade.dart';
copied to clipboard
4. use it #
Methods available: #



Method
Status




CurrentUser
V


registerWithEmailAndPassword
V


signInWithEmailAndPassword
V


SignInWithGoogle
V


SignInWithApple
V


SignInAnonym
V


SigninWithGitHub
V


SignInWithFacebook
X


SignInWithInstagram
X


SignOut
V


userState
V


resetPassword
V



Prepare for Android and ios: #

Android

add to your AndroidManifest.xml:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="[your firebase project name].firebaseapp.com" />
</intent-filter>
copied to clipboard

iOS

Add to your info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>[your firebase project name].firebaseapp.com</string>
<key>CFBundleURLSchemes</key>
<array>
<string>https</string>
</array>
</dict>
</array>
copied to clipboard
First instanciate FirebaseAuthFacade and inject GoogleSignIn and FirebaseAuth.
Then you have to call the method call() on the instance => authFacade()
callbackUrl is required, you can find it in your firebase panel in the github sign in method or apple sign in method.
You can use injectable like this and inject it into your Bloc:
import 'package:flutter_firebase_auth_facade/flutter_firebase_auth_facade.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:injectable/injectable.dart';

@module
abstract class PackagesInjectableModule {
@lazySingleton
IAuthFacade get authFacade {
final _firebaseAuth = FirebaseAuth.instance;
final _googleSignIn = GoogleSignIn();
final authFacade = FirebaseAuthFacade(_firebaseAuth, _googleSignIn);
authFacade(
callbackUrl:
environment == Environment.dev ? callbackUrlDev : callbackUrl,
githubClientId:
environment == Environment.dev ? githubClientIdDev : githubClientId,
githubSecret:
environment == Environment.dev ? githubSecretDev : githubSecret,
);
return authFacade;
}
}
copied to clipboard
Real life example #

You can find a real life app open source being build here:
flutterence

Simple example #
The sign in methods are returning a Future<Either<AuthFailure, unit>>, so you'll have to
use Dartz and fold the result like this:
final failureOrSuccess = _authFacade.signInWithGitHub();
failureOrSuccess.fold(
(failure) => print(failure), // Handle the failure here
(success) => print("User logged in")// handle the user here
);

copied to clipboard
Handle error #
The AuthFailure class use Freezed with code generation so you can use Unions/sealed class feature:
failure.map(

);
failure.maybeMap();
failure.when();
//etc...
copied to clipboard
Dependencies #

flutterFire
freezed
SignInWithApple
dartz

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.