signInWithGoogle static method
- BuildContext context, {
- bool? signInWithRedirect,
- dynamic onError()?,
- dynamic onSignInSuccessful()?,
Initates a GoogleSignIn and the AuthManager changes the screen to the destinationFragment
Shows a traditional OAuth Pop up window on the Web and a normal GoogleSignIn Modal on android
Please ensure you have added your SHA-1 Key to Firebase to work on Mobile and ensure to have your GoogleSignInClientID in a meta tag in /web/index.html.
Enable Google Authentication in your Firebase Authentication Console for this to work
context
is neccessary
signInWithRedirect
(default false) is a boolean that is Flutter Web only and basically allows you to chose if you want your
OAuth Screen to be a popup or a redirect. Setting this to true, will use a redirect
onError
a Callback for any Error that may occur
onSignInSuccessful
a Callback to perform any action after a successful SignIn
Implementation
static Future<User?> signInWithGoogle(
BuildContext context, {
bool? signInWithRedirect,
Function(String)? onError,
Function(User)? onSignInSuccessful,
}) async {
return await Provider.of<FireAuthProvider>(
context,
listen: false,
).signInWithGoogle(
allowSignInWithRedirect: signInWithRedirect ?? false,
onError: onError,
onSignInSuccessful: onSignInSuccessful,
);
}