import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:project/models/user_data.dart';
import 'package:project/screens/home_screen.dart';
import 'package:project/screens/login_screen.dart';
class AuthService{
// declaring in
static final _auth = FirebaseAuth.instance;
static final _firestore = Firestore.instance;
// signUp
static void signUpUser(BuildContext context, String name, String email, String password) async{
try{
AuthResult authResult = await _auth.createUserWithEmailAndPassword(
email: email,
password: password,
);
FirebaseUser signedInUser = authResult.user;
if(signedInUser!=null){
_firestore.collection('/users').document(signedInUser.uid).setData({
'name': name,
'email': email,
'profileImageUrl': '',
});
Navigator.pushReplacementNamed(context, MenuOptionsScreen.id);
}
} catch(e){
print(e);
}
}
//signOut
static void logout(BuildContext context){
_auth.signOut();
Navigator.pushReplacementNamed(context, LoginScreen.id);
}
// login
static void login(context,String email, String password) async{
try{
final user= await _auth.signInWithEmailAndPassword(
email: email,
password: password,
);
if(user!=null){
print(user);
Navigator.pushReplacementNamed(context, MenuOptionsScreen.id);
}
}catch(e){
print(e);
}
}
// Reset Password
static void sendPasswordResetEmail(context, String email) async{
try{
return _auth.sendPasswordResetEmail(email: email);
}catch(e){
print(e);
}
}
}
ящик: ящик (дочерний элемент: столбец (дочерние элементы: [UserAccountsDrawerHeader (accountName: Text ('Martin'), стиль: TextStyle (цвет: Colors.white),), accountEmail: Text ('martinmwenda026@gmail.com', style: TextStyle (color: Colors.white),), currentAccountPicture: CircleAvatar (child: Text ('M'), backgroundColor: Colors.white,
),
),
SizedBox(
height: 10.0,
),
ListTile(
leading: Icon(Icons.shopping_cart),
title: Text('My Orders', style: TextStyle(),),
),
SizedBox(
height: 10.0,
),
ListTile(
leading: Icon(Icons.payment),
title: Text('Payment', style: TextStyle(),),
onTap: (){
Navigator.pushReplacementNamed(context, Payment.id);
},
),
SizedBox(
height: 10.0,
),
ListTile(
leading: Icon(Icons.share),
title: Text('Invite Friends'),
),
SizedBox(
height: 10.0,
),
Divider(),
SizedBox(
height: 10.0,
),
ListTile(
leading: Icon(Icons.card_membership),
title: Text('Become Helper'),
),
SizedBox(
height: 10.0,
),
ListTile(
leading: Icon(Icons.help),
title: Text('Help'),
onTap: (){
Navigator.pushReplacementNamed(context, HelpScreen.id);
},
),
SizedBox(
height: 10.0,
),
ListTile(
leading: Icon(Icons.exit_to_app),
title: Text('Logout'),
onTap: (){
AuthService.logout(context);
},
)
],
),
),
Заголовок 2 ## У меня есть проблема в получать информацию из пожарного магазина и отображать электронную почту в своем ящике флаттера, требуя простых шагов, которые помогут мне и помогут мне в изучении флаттера.