I'm trying to create a simple banking app with flutter.I'm creating the user login information myself and trying to auth them with firebase. I already coded the authentication part of the app.Here is the code:
import 'package:banking_app_firebase/screens/customers_info.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart';
import '../constants.dart';
class LoginScreen extends StatefulWidget {
static const String id = 'login_screen';
const LoginScreen({Key? key}) : super(key: key);
@override
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
final _auth = FirebaseAuth.instance;
bool showSpinner = false;
String? email;
String? password;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: ModalProgressHUD(
inAsyncCall: showSpinner,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Flexible(
child: Hero(
tag: 'logo',
child: Container(
height: 100,
child: Image.network(
"https://image.flaticon.com/icons/png/512/662/662622.png",
),
),
),
),
SizedBox(height: 20),
TextField(
keyboardType: TextInputType.emailAddress,
textAlign: TextAlign.center,
onChanged: (value) {
email = value;
},
decoration:
kTextFieldDecoration.copyWith(hintText: 'Enter your email'),
),
SizedBox(
height: 20,
),
TextField(
obscureText: true,
textAlign: TextAlign.center,
onChanged: (value) {
password = value;
},
decoration: kTextFieldDecoration.copyWith(
hintText: "Enter your password"),
),
SizedBox(
height: 24,
),
Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Material(
elevation: 5,
color: Colors.white,
borderRadius: BorderRadius.circular(30),
child: MaterialButton(
onPressed: () async {
setState(() {
showSpinner = true;
});
try {
final user = await _auth.signInWithEmailAndPassword(
email: email!, password: password!);
if (user != null) {
Navigator.pushNamed(context, CustomerScreen.id);
}
setState(() {
showSpinner = true;
});
} catch (e) {
print(e);
}
},
height: 42,
child: Text(
"Login",
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
),
),
],
),
),
),
);
;
}
}
Sample Users:
However, I don't know how to sync these information with my database so I can reach the data in the database. Here is my example database:
How can I get the informations about customers like name,surname,balance after auth is successful? I mean, how can I tell the Firebase, the auth email and password same as firestore database?

