Building a Beautiful Login Page with Flutter

Building a Beautiful Login Page with Flutter

Create a clean, responsive, and attractive login screen step-by-step

Flutter is known for building stunning UI with ease. In this tutorial, we’ll walk through how to design a beautiful login page using Flutter—perfect for beginners or anyone creating an authentication flow.


🧰 What You’ll Need

  • Flutter SDK installed

  • Any IDE (Android Studio, VS Code)

  • Basic knowledge of Dart & Widgets


✅ Features of Our Login Page

  • Responsive layout

  • Clean design with rounded text fields

  • Password visibility toggle

  • Login button

  • "Forgot Password?" and "Sign Up" links


πŸ—️ Step 1: Basic Project Setup

flutter create login_page_demo cd login_page_demo

Open lib/main.dart and replace with:

import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Login UI', theme: ThemeData(primarySwatch: Colors.blue), home: LoginPage(), debugShowCheckedModeBanner: false, ); } }

🧱 Step 2: Create the Login Page Layout

class LoginPage extends StatefulWidget { @override _LoginPageState createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { bool _obscureText = true; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[200], body: Center( child: SingleChildScrollView( padding: EdgeInsets.all(24), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon(Icons.lock, size: 100, color: Colors.blueAccent), SizedBox(height: 20), Text("Welcome Back!", style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold)), SizedBox(height: 30), _buildTextField("Email", false), SizedBox(height: 15), _buildTextField("Password", true), SizedBox(height: 10), Align( alignment: Alignment.centerRight, child: TextButton( onPressed: () {}, child: Text("Forgot Password?") ), ), SizedBox(height: 20), ElevatedButton( onPressed: () {}, child: Padding( padding: EdgeInsets.symmetric(horizontal: 60, vertical: 15), child: Text("Login", style: TextStyle(fontSize: 18)), ), ), SizedBox(height: 25), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Don’t have an account? "), GestureDetector( onTap: () {}, child: Text("Sign Up", style: TextStyle(color: Colors.blue)), ), ], ) ], ), ), ), ); } Widget _buildTextField(String hint, bool isPassword) { return TextField( obscureText: isPassword ? _obscureText : false, decoration: InputDecoration( labelText: hint, border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)), suffixIcon: isPassword ? IconButton( icon: Icon( _obscureText ? Icons.visibility_off : Icons.visibility, ), onPressed: () { setState(() { _obscureText = !_obscureText; }); }, ) : null, filled: true, fillColor: Colors.white, ), ); } }

🎨 Optional Enhancements

  • Add background gradients or images

  • Use GoogleFonts for custom typography

  • Integrate form validation

  • Add animation using AnimatedOpacity or Hero


πŸš€ Final Thoughts

With just a few lines of code, you’ve built a modern, clean, and functional login page in Flutter. From here, you can:

  • Connect it to Firebase Auth or a REST API

  • Add a loading spinner

  • Create signup and dashboard screens

Flutter makes UI building simple, fun, and fast. 



Read More 



Comments

Popular posts from this blog

Tosca System Requirements and Installation Guide (Step-by-Step)

How to Install Selenium for Python Step-by-Step

Tosca Commander: A Beginner’s Overview