mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2026-08-24 16:50:47 +00:00
- Bump all apps to sdk >=3.0.0 <4.0.0 and add flutter_lints + a shared analysis_options.yaml to every app (flutter analyze is now green repo-wide) - Fix real compile errors in firebase_google_authentication and image_editor, plus deprecated APIs (Matrix4, SvgPicture.color, textScaleFactor), missing async 'mounted' guards, and misc lints via dart fix + manual fixes - Align pubspec 'name' with each folder and Android namespace/applicationId with the documented github.nisrulz.* convention - Convert bmi_calculator from a legacy Flutter module to a standard app with a proper android/ scaffold; fix missing android:exported in launcher manifests across 22 apps so all Android builds pass - Untrack generated build files (GeneratedPluginRegistrant, .flutter-plugins-dependencies) and ignore them
44 lines
1.1 KiB
Dart
44 lines
1.1 KiB
Dart
import 'package:firebase_auth/firebase_auth.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:google_sign_in/google_sign_in.dart';
|
|
|
|
class GoogleSignInProvider extends ChangeNotifier {
|
|
final googleSignIn = GoogleSignIn.instance;
|
|
|
|
GoogleSignInAccount? _user;
|
|
User? user1;
|
|
GoogleSignInAccount get user => _user!;
|
|
String? userId;
|
|
FirebaseAuth auth = FirebaseAuth.instance;
|
|
|
|
Future googleLogin() async {
|
|
try {
|
|
await googleSignIn.initialize();
|
|
final googleUser = await googleSignIn.authenticate();
|
|
_user = googleUser;
|
|
|
|
final googleAuth = googleUser.authentication;
|
|
|
|
final credentials = GoogleAuthProvider.credential(
|
|
idToken: googleAuth.idToken,
|
|
);
|
|
|
|
await FirebaseAuth.instance.signInWithCredential(credentials);
|
|
notifyListeners();
|
|
} catch (e) {
|
|
print(e.toString());
|
|
}
|
|
}
|
|
|
|
Future googleLogout() async {
|
|
try {
|
|
print('Logging Out');
|
|
await googleSignIn.disconnect();
|
|
FirebaseAuth.instance.signOut();
|
|
} catch (e) {
|
|
FirebaseAuth.instance.signOut();
|
|
}
|
|
notifyListeners();
|
|
}
|
|
}
|