Skip to content

Instantly share code, notes, and snippets.

@NoaTubic
Last active April 25, 2022 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NoaTubic/8674a4a2d99dc9f8e54d0f1e5e85d480 to your computer and use it in GitHub Desktop.
Save NoaTubic/8674a4a2d99dc9f8e54d0f1e5e85d480 to your computer and use it in GitHub Desktop.
Future<User> signInOrCreateAccount(
BuildContext context, Future<UserCredential> Function() signInFunc) async {
try {
final userCredential = await signInFunc();
await maybeCreateUser(userCredential.user);
return userCredential.user;
} on FirebaseAuthException catch (e) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Error: ${e.message}')),
);
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment