mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-11-09 04:58:58 +00:00
taskplanning_app
This commit is contained in:
147
Plan_Tasks/Taskplanning_app/lib/signIn.dart
Normal file
147
Plan_Tasks/Taskplanning_app/lib/signIn.dart
Normal file
@@ -0,0 +1,147 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;
|
||||
import 'package:github.nisrulz.todo_app/Home.dart';
|
||||
import 'package:github.nisrulz.todo_app/signUp.dart';
|
||||
|
||||
class Signin extends StatefulWidget {
|
||||
const Signin({Key? key});
|
||||
|
||||
@override
|
||||
State<Signin> createState() => _SigninState();
|
||||
}
|
||||
|
||||
class _SigninState extends State<Signin> {
|
||||
firebase_auth.FirebaseAuth firebaseauth = firebase_auth.FirebaseAuth.instance;
|
||||
final TextEditingController _emailcontroller = TextEditingController();
|
||||
final TextEditingController _passwordcontroller = TextEditingController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailcontroller.dispose();
|
||||
_passwordcontroller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _Signin() async {
|
||||
try {
|
||||
final String email = _emailcontroller.text;
|
||||
final String password = _passwordcontroller.text;
|
||||
|
||||
await firebaseauth.signInWithEmailAndPassword(
|
||||
email: email,
|
||||
password: password,
|
||||
);
|
||||
|
||||
Get.snackbar(
|
||||
"Sign In Success",
|
||||
"You have successfully signed in.",
|
||||
backgroundColor: Colors.green,
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
duration: Duration(seconds: 3),
|
||||
);
|
||||
|
||||
|
||||
Get.to(() => HomePage());
|
||||
} catch (e) {
|
||||
Get.snackbar(
|
||||
"Sign In Error",
|
||||
e.toString(),
|
||||
backgroundColor: Colors.red,
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
duration: Duration(seconds: 3),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
height: Get.size.height,
|
||||
width: Get.size.width,
|
||||
color: Colors.black,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
"Login ",
|
||||
style: TextStyle(
|
||||
color: Colors.green,
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
|
||||
SizedBox(height: 20),
|
||||
Container(
|
||||
width: Get.size.width - 60,
|
||||
height: 60,
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Center(
|
||||
child: TextField(
|
||||
controller: _emailcontroller,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Email',
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
Container(
|
||||
width: Get.size.width - 60,
|
||||
height: 60,
|
||||
child: Card(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
||||
child: Center(
|
||||
child: TextField(
|
||||
controller: _passwordcontroller,
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Password',
|
||||
border: InputBorder.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: _Signin,
|
||||
child: Text("Sign In"),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.to(() => Signup());
|
||||
},
|
||||
child: const Text(
|
||||
"Don't have an account? Sign Up",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
decoration: TextDecoration.underline,
|
||||
fontSize: 18),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user