Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved some depreciation errors #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import 'package:chatapp/helper/helperfunctions.dart';
import 'package:chatapp/views/chatrooms.dart';
import 'package:flutter/material.dart';

void main() {
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}

Expand Down
12 changes: 6 additions & 6 deletions lib/services/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import 'package:google_sign_in/google_sign_in.dart';
class AuthService {
final FirebaseAuth _auth = FirebaseAuth.instance;

User _userFromFirebaseUser(FirebaseUser user) {
User _userFromFirebaseUser(User user) {
return user != null ? User(uid: user.uid) : null;
}

Future signInWithEmailAndPassword(String email, String password) async {
try {
AuthResult result = await _auth.signInWithEmailAndPassword(
UserCredential result = await _auth.signInWithEmailAndPassword(
email: email, password: password);
FirebaseUser user = result.user;
User user = result.user;
return _userFromFirebaseUser(user);
} catch (e) {
print(e.toString());
Expand Down Expand Up @@ -44,20 +44,20 @@ class AuthService {
}
}

Future<FirebaseUser> signInWithGoogle(BuildContext context) async {
Future<User> signInWithGoogle(BuildContext context) async {
final GoogleSignIn _googleSignIn = new GoogleSignIn();

final GoogleSignInAccount googleSignInAccount =
await _googleSignIn.signIn();
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount.authentication;

final AuthCredential credential = GoogleAuthProvider.getCredential(
final AuthCredential credential = GoogleAuthProvider.Credential(
idToken: googleSignInAuthentication.idToken,
accessToken: googleSignInAuthentication.accessToken);

AuthResult result = await _auth.signInWithCredential(credential);
FirebaseUser userDetails = result.user;
User userDetails = result.user;

if (result == null) {
} else {
Expand Down