I am a beginner in developing Flutter application, and try to create a sample application for educational purpose. Last few weeks I decided to do a sample application in flutter that have no inbuilt login or register section because it's have social login options like Facebook and Google. I searched the web and got many code examples for how to implement Facebook and Google authentication in Flutter application.
I have a doubt about this social login implementation maybe it's happening because of lack of working experience in mobile application architecture level. At this point I am asking a question to myself "How to manage social login users in applications"
I have a solution like if the user can login ed successfully, store the user details into our (Firebase) db check the user email exists in database if there is no matching entries in db it will create a new user in database or if exists update the last login date time of that particular user. Because this application shows some user related data in other forms, it's work on the basis of logined userid, so I need to store the logined user details in the database.
Step 1: First create the flutter project in your IDE. Step 2: After that just remove the default code and start from scratch. Step 3: Now just import the material library and call the runApp( ) function into the main function name as GoogleSignIn. Step 4: Now make a stateful widget with the name 'GoogleSignIn'.
Step 1: First create the flutter project in your IDE. Step 2: After that just remove the default code and start from scratch. Step 3: Now just import the material library and call the runApp ( ) function into the main function name as GoogleSignIn. Step 4: Now make a stateful widget with the name ‘ GoogleSignIn‘.
When it comes to Flutter app development, we can come up with innovative features and functionality to make people’s lives more comfortable and easy. Recently, while discussing different technical topics with my colleagues, I thought I should make one blog on social authentication with multiple platforms like Google, Facebook & Twitter.
Add a StackedLogger into the annotation. When that's complete you can run flutter pub run build_runner build --delete-conflicting-outputs Now that we have the model lets go over the plan of getting the user into our system from the code side. The first thing we need to do is create a user document for the user that was signed in.
F irebase authentication, for the most part, helps bolster diverse user authentication certifications. It is, for the most part, a mobile backend as a service that presents you with amazing highlights for the advancement of flutter applications.
Your proposed solution is good enough. The returned id is unique for your app.
Use the id returned to your app as the identifier for users in your app.
Checkout this answer on unique id
Just leaving the social_login plugin here
// Import package import 'package:social_login/social_login.dart'; // Instantiate it final socialLogin = SocialLogin(); //Before calling any methods, set the configuration socialLogin.setConfig(SocialConfig( facebookAppId: FACEBOOK_APP_ID, googleWebClientId: GOOGLE_WEB_CLIENT_ID, /*In case a Google tokenId is needed*/ twitterConsumer: TWITTER_CONSUMER_KEY, twitterSecret: TWITTER_CONSUMER_SECRET, )); // Get current logged user final FacebookUser facebookUser = await socialLogin.getCurrentFacebookUser(); final GoogleUser googleUser = await socialLogin.getCurrentGoogleUser(); final TwitterUser twitterUser = await socialLogin.getCurrentTwitterUser(); //Log in social networks final FacebookUser facebookUser = await socialLogin.logInFacebookWithPermissions(FacebookPermissions.DEFAULT); final GoogleUser googleUser = await socialLogin.logInGoogle(); final TwitterUser twitterUser = await socialLogin.logInTwitter(); //Log out from social networks await socialLogin.logOutFacebook(); await socialLogin.logOutGoogle(); await socialLogin.logOutTwitter();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With