Using this package to sign in all social platform like Google login, Apple login, Facebook, LinkedIn
Features
- All Social Sign In implementations in a single package.
- Login on iOS and Android.
- Reduce line of code and package installation
Getting started
before write a code :
- It is necessary to create firebase project and insert google json file in your project and enable Authentication
- It is necessary to configure the platform which you are using
- Import firebase_auth package for accessing User class
Google login
Apple login
Facebook login
LinkedIn login
Usage
just call this methods
Google login
void googleLogin() {
SocialLoginUtils().signInWithGoogle(context,isDisplayProgressBar: true,).then((userData) {
//return type is User ('package:firebase_auth/firebase_auth.dart')
if(userData!=null){
Navigator.of(context)
.push(PageRouteBuilder(
pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) =>
DashboardPage(userData:userData),
transitionDuration: Duration(seconds: 0),
));
}
});
}
Apple login
if platform is android, pass clientID is mandatory
void appleLogin() {
SocialLoginUtils().appleLogin(context,Platform.isAndroid,isDisplayProgressBar: true,
clientID: "as_given_doc"
).then((userData) {
//return type is User ('package:firebase_auth/firebase_auth.dart')
if(userData!=null){
Navigator.of(context)
.push(PageRouteBuilder(
pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) =>
DashboardPage(userData:userData),
transitionDuration: Duration(seconds: 0),
));
}
});
}
Facebook login
void facebookLogin() {
SocialLoginUtils().signInWithFacebook(context,isDisplayProgressBar: true,).then((userData) {
//return type is User ('package:firebase_auth/firebase_auth.dart')
if(userData!=null){
Navigator.of(context)
.push(PageRouteBuilder(
pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) =>
DashboardPage(userData:userData),
transitionDuration: Duration(seconds: 0),
));
}
});
}
LinkedIn login
for logout set destroySession=false;
void linkedInLogin() {
SocialLoginUtils().signInWithLinkedIn(context,isDisplayProgressBar: true,
clientId:'CLIENT_ID' ,clientSecret:'CLIENT_SECRET' ,redirectUrl: 'REDIRECT_URL',
appBar:AppBar(title: Text("All Social login"),),
destroySession: false
).then((userData) {
//return type is MAP<String, dynamic>
if(userData!=null){
Navigator.of(context)
.push(PageRouteBuilder(
pageBuilder: (BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) =>
DashboardPage(mapUserData:userData),
transitionDuration: Duration(seconds: 0),
));
}
});
}
Additional information
The main goal of writing this package to reduce line of code. Once sign in you need to Logout.