Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91234080
FirebaseAuthService.dart
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 9, 05:31
Size
1 KB
Mime Type
text/x-c++
Expires
Mon, Nov 11, 05:31 (2 d)
Engine
blob
Format
Raw Data
Handle
22226155
Attached To
R12599 MStream: Microlearning video recommendation experiment
FirebaseAuthService.dart
View Options
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
class FlutterFireAuthService {
final FirebaseAuth _firebaseAuth;
FlutterFireAuthService(this._firebaseAuth);
Stream<User?> get authStateChanges => _firebaseAuth.idTokenChanges();
Future<void> signOut({required BuildContext context}) async {
await _firebaseAuth.signOut();
Navigator.pushReplacementNamed(context, '/');
}
Future<String> signIn(
{required String email, required String password, required BuildContext context}) async {
try {
await _firebaseAuth.signInWithEmailAndPassword(
email: email, password: password);
Navigator.pushReplacementNamed(context, '/homeScreen');
return "Success";
} on FirebaseAuthException catch (e) {
print(e.toString());
return e.code;
}
}
Future<String> signUp(
{required String email, required String password, required BuildContext context}) async {
try {
await _firebaseAuth.createUserWithEmailAndPassword(
email: email, password: password);
Navigator.pushNamed(context, '/mayScreen');
return "Success";
} on FirebaseAuthException catch (e) {
return e.code;
}
}
}
Event Timeline
Log In to Comment