Ad Code

Login UI created by flutter

 Login UI created by flutter

#flutter #Login_page




Source code : 

main.dart :
import 'package:flutter/material.dart';
import 'package:login_ui/pages/login_page.dart';

void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: LoginPage(),
);
}
}


login_page.dart : 

import 'package:flutter/material.dart';
import 'package:login_ui/components/button.dart';
import 'package:login_ui/components/text_field.dart';

class LoginPage extends StatefulWidget {
const LoginPage({Key? key}) : super(key: key);

@override
State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
final emailController = TextEditingController();
final passwordController = TextEditingController();

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[350],
body: SafeArea(
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [


 Image.asset(
"assets/images/key.png",
height: 150,
),

const SizedBox(
height: 30,
),
const Text(
'Welcome back, you\'ve been missed',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
),
const SizedBox(
height: 25,
),
MyTextField(
controller: emailController,
hintText: 'Email',
obscureText: false),
const SizedBox(
height: 10,
),
MyTextField(
controller: passwordController,
hintText: 'Password',
obscureText: true),
const SizedBox(
height: 10,
),
const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(''),
Text(
'Forgotten password',
style: TextStyle(color: Colors.blue, fontWeight: FontWeight.bold),
),
],
),
const SizedBox(
height: 15,
),
MyButton(onTap: () {}, text: 'Sign In'),
const SizedBox(
height: 10,
),
const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Not a member?'),
SizedBox(
width: 5,
),
Text(
'Register here',
style: TextStyle(color: Colors.blue),
),
],
),
],
),
),
),
),
);
}
}

text_field.dart :

import 'package:flutter/material.dart';

class MyTextField extends StatelessWidget {
final TextEditingController controller;
final String hintText;
final bool obscureText;

const MyTextField(
{Key? key,
required this.controller,
required this.hintText,
required this.obscureText})
: super(key: key);

@override
Widget build(BuildContext context) {
return TextField(
controller: controller,
obscureText: obscureText,
decoration: InputDecoration(
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.white)
),
fillColor: Colors.grey[200],
filled: true,
hintText: hintText,
hintStyle: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
)
),
);
}
}

button.dart : 

import 'package:flutter/material.dart';

class MyButton extends StatelessWidget {
final Function()? onTap;
final String text;

const MyButton({Key? key, required this.onTap, required this.text})
: super(key: key);

@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: Text(
text,
style: const TextStyle(color: Colors.white,fontWeight: FontWeight.bold ,fontSize: 18),
),
),
);
}
}

Post a Comment

0 Comments