mirror of
https://github.com/flutter/samples.git
synced 2026-04-05 03:01:19 +00:00
Migrate web dashboard to null safety (#928)
* update dependencies * Update to cloud_firestore 2.x.x * run dart migrate * Fix analyzer warnings from null safety migration * Fix errors resulting from null safety migration * Fix info level warnings * run flutter format * fix tests * remove unused import, format
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:firebase_auth/firebase_auth.dart' hide FirebaseUser;
|
||||
import 'package:firebase_auth/firebase_auth.dart' hide User;
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:google_sign_in/google_sign_in.dart';
|
||||
|
||||
@@ -25,21 +25,21 @@ class FirebaseAuthService implements Auth {
|
||||
}
|
||||
|
||||
Future<User> _signIn() async {
|
||||
GoogleSignInAccount googleUser;
|
||||
GoogleSignInAccount? googleUser;
|
||||
if (await isSignedIn) {
|
||||
googleUser = await _googleSignIn.signInSilently();
|
||||
} else {
|
||||
googleUser = await _googleSignIn.signIn();
|
||||
}
|
||||
|
||||
var googleAuth = await googleUser.authentication;
|
||||
var googleAuth = await googleUser!.authentication;
|
||||
|
||||
var credential = GoogleAuthProvider.getCredential(
|
||||
var credential = GoogleAuthProvider.credential(
|
||||
accessToken: googleAuth.accessToken, idToken: googleAuth.idToken);
|
||||
|
||||
var authResult = await _auth.signInWithCredential(credential);
|
||||
|
||||
return _FirebaseUser(authResult.user.uid);
|
||||
return _FirebaseUser(authResult.user!.uid);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'auth.dart';
|
||||
|
||||
class MockAuthService implements Auth {
|
||||
@@ -12,11 +10,6 @@ class MockAuthService implements Auth {
|
||||
|
||||
@override
|
||||
Future<User> signIn() async {
|
||||
// Sign in will randomly fail 25% of the time.
|
||||
var random = Random();
|
||||
if (random.nextInt(4) == 0) {
|
||||
throw SignInException();
|
||||
}
|
||||
return MockUser();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user