Skip to content

Instantly share code, notes, and snippets.

@red-star25
Last active April 24, 2022 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save red-star25/5eb610bf726a5a7dc2d7958f92bb91a8 to your computer and use it in GitHub Desktop.
Save red-star25/5eb610bf726a5a7dc2d7958f92bb91a8 to your computer and use it in GitHub Desktop.
import 'package:bloc_auth/presentation/SignUp/sign_up.dart';
import 'package:email_validator/email_validator.dart';
import 'package:flutter/material.dart';
class SignIn extends StatefulWidget {
const SignIn({Key? key}) : super(key: key);
@override
State<SignIn> createState() => _SignInState();
}
class _SignInState extends State<SignIn> {
final _formKey = GlobalKey<FormState>();
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
@override
void dispose() {
_emailController.dispose();
_passwordController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("SignIn"),
),
body: Center(
child: Padding(
padding: const EdgeInsets.all(18.0),
child: SingleChildScrollView(
reverse: true,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Sign In",
style: TextStyle(
fontSize: 38,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 18,
),
Center(
child: Form(
key: _formKey,
child: Column(
children: [
TextFormField(
keyboardType: TextInputType.emailAddress,
controller: _emailController,
decoration: const InputDecoration(
hintText: "Email",
border: OutlineInputBorder(),
),
autovalidateMode:
AutovalidateMode.onUserInteraction,
validator: (value) {
return value != null &&
!EmailValidator.validate(value)
? 'Enter a valid email'
: null;
},
),
const SizedBox(
height: 10,
),
TextFormField(
keyboardType: TextInputType.text,
controller: _passwordController,
decoration: const InputDecoration(
hintText: "Password",
border: OutlineInputBorder(),
),
autovalidateMode:
AutovalidateMode.onUserInteraction,
validator: (value) {
return value != null && value.length < 6
? "Enter min. 6 characters"
: null;
},
),
const SizedBox(
height: 12,
),
SizedBox(
width: MediaQuery.of(context).size.width * 0.7,
child: ElevatedButton(
onPressed: () {},
child: const Text('Sign In'),
),
)
],
),
),
),
IconButton(
onPressed: () {},
icon: Image.network(
"https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Google_%22G%22_Logo.svg/1200px-Google_%22G%22_Logo.svg.png",
height: 30,
width: 30,
),
),
const Text("Don't have an account?"),
OutlinedButton(
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const SignUp()),
);
},
child: const Text("Sign Up"),
)
],
),
),
),
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment