firebase_ui_oauth_google 1.2.6 firebase_ui_oauth_google: ^1.2.6 copied to clipboard
Firebase UI widgets for authentication & OAuth.
Firebase UI OAuth Google #
Google Sign In for Firebase UI Auth
Installation #
Add dependencies
flutter pub add firebase_ui_auth
flutter pub add firebase_ui_oauth_google
flutter pub global activate flutterfire_cli
flutterfire configure
Enable Google provider on firebase console.
Usage #
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
import 'package:firebase_ui_oauth_google/firebase_ui_oauth_google.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
FirebaseUIAuth.configureProviders([
GoogleProvider(clientId: 'clientId'),
]);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key}) ;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: SignInScreen(
actions: [
AuthStateChangeAction<SignedIn>((context, state) {
// redirect to other screen
})
],
),
);
}
}
Alternatively you could use the OAuthProviderButton
class MyScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return AuthStateListener<OAuthController>(
listener: (oldState, newState, controller) {
if (newState is SignedIn) {
// navigate to other screen.
}
},
child: OAuthProviderButton(
provider: GoogleProvider(clientId: 'clientId'),
),
);
}
}
Also there is a standalone version of the GoogleSignInButton
class MyScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GoogleSignInButton(
clientId: 'clientId',
loadingIndicator: CircularProgressIndicator(),
onSignedIn: (UserCredential credential) {
// perform navigation.
}
);
}
}
For issues, please create a new issue on the repository.
For feature requests, & questions, please participate on the discussion thread.
To contribute a change to this plugin, please review our contribution guide and open a pull request.
Please contribute to the discussion with feedback.