flutter_firebase_extra 0.2.0
flutter_firebase_extra: ^0.2.0 copied to clipboard
Manage authentication with firebase in an extremely simple way
flutter_firebase_extra #
Manage user auth in minutes. This package uses (provider package)
AUTH Basic ussage #
-
Your app must be a child of 'ChangeNotifierProvider'
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<AuthState>(
child: MaterialApp(
home: ParentPage(),
),
create: (_) => AuthState(),
);
}
}
- The parent page manages the screen shown in each of the authentication states
class ParentPage extends StatelessWidget{
@override
Widget build(BuildContext context) {
return AuthManagerWidget(
splashScreen: MySplashScreen(), //optional
introductionScreen: MyIntroductionScreen(), //optional, user not logged
loginScreen: MyLoginScreen(), // user not logged, the introduction has been completed
mainScreen: MyMainScreen(), // user logged (email, google, apple or anonymous)
);
}
}
- Set introduction as completed
AuthState authState = Provider.of(context);
authState.setIntroductionCompleted(true);
- Prebuilt LoginScreen
LoginScreen(
backgroundColor: Colors.purple,
expandedWidget: Center(child: Container(height: 200, width: 300, color: Colors.red,),),
emailLogin: (context){
return EmailLoginScreen(
appBar: AppBar(
title: Text("MyApp Login"),
),
mainColor: Colors.blue,
privacyUrl: "https://www.myprivacyurl.com",
termsUrl: "https://mytermsurl.com",
);
},
)
- Logout
AuthState authState = Provider.of(context);
authState.signOut();