In this tutorial, we’ll learn how to create this beautiful Flutter login and registration UI design. The complete source code of the mentioned Flutter login and registration UI screen design will be provided in the end.
Outline
- Introduction: Flutter Login and Registration Source Code
- Beautiful Flutter Login and Registration Design Template Source Code
- Conclusion
Introduction: Flutter Login And Registration Source Code
We’ve created this beautiful Flutter login and signup design by using multiple Flutter widgets. We’ve created a toggle type design which can be used to show login or registration form.
Widgets that are used in creating this amazing Flutter login and registration UI design are listed below:
- Flutter Column Widget
- Flutter Snackbar Widget
- Flutter Row Widget
- Flutter Text Widget
- Flutter Single Child Scroll View Widget
- Flutter Padding Widget
- Flutter Textfield Widget
- Flutter Gesture Detector Widget
- Flutter Inkwell Widget
- Flutter Container Widget
I’ve written detailed articles on the widgets listed above, you can check them out using the search box or menu bar of this site.
Flutter login and registration source code is available in the below section.
Try to understand how every Flutter widget is doing its role in this beautiful login and registration template design and implement this design from scratch.
You can paste this code inside your main file. No additional packages required. Hope you’ll like it. Also, try to customize it according to your set of requirements.
Beautiful Flutter Login and Registration Design Template Source Code
// amazing flutter login and registration source code import 'package:flutter/material.dart'; main() { runApp(myApp()); } class myApp extends StatelessWidget { const myApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: LoginScreen(), ); } } // beautiful Flutter login and registration source code class LoginScreen extends StatefulWidget { const LoginScreen({Key? key}) : super(key: key); @override State<LoginScreen> createState() => _LoginScreenState(); } class _LoginScreenState extends State<LoginScreen> { bool showPassword = false; bool showConfirmPassword = false; bool isLoginSelected = true; @override Widget build(BuildContext context) { // flutter login and registration source code return SafeArea( child: Scaffold( backgroundColor: Colors.white, body: SizedBox( height: double.infinity, width: double.infinity, child: SingleChildScrollView( padding: EdgeInsets.only(top: 200), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ // flutter login and registration source code Align( alignment: Alignment.topCenter, child: Container( margin: EdgeInsets.only(bottom: 10), height: 40, width: 150, decoration: BoxDecoration( boxShadow: [ BoxShadow( offset: Offset(4, 4), blurRadius: 5, spreadRadius: 0, color: Colors.grey.shade400) ], borderRadius: BorderRadius.circular(50), color: Colors.white), child: Row( // flutter login and registration source code design UI children: [ !isLoginSelected ? Expanded( child: Center( child: GestureDetector( onTap: () { setState(() { print('tap'); isLoginSelected = true; }); }, child: Text( 'Login', style: TextStyle( color: Colors.blue, fontSize: 12, fontWeight: FontWeight.w500), ), ), )) : Expanded( child: Container( alignment: Alignment.center, decoration: BoxDecoration( boxShadow: [ BoxShadow( offset: Offset(4, 4), blurRadius: 5, spreadRadius: 0, color: Colors.grey.shade400) ], borderRadius: BorderRadius.circular(50), color: Colors.white), child: Text( 'Login', style: TextStyle( color: Colors.blue, fontSize: 12, fontWeight: FontWeight.w500), ), )), isLoginSelected ? Expanded( child: Center( child: TextButton( onPressed: () { setState(() { print('tap'); isLoginSelected = false; }); }, child: Text( 'Register', style: TextStyle( color: Colors.blue, fontSize: 12, fontWeight: FontWeight.w500), ), ), )) : Expanded( child: Container( alignment: Alignment.center, decoration: BoxDecoration( boxShadow: [ BoxShadow( offset: Offset(4, 4), blurRadius: 5, spreadRadius: 0, color: Colors.grey.shade400) ], borderRadius: BorderRadius.circular(50), color: Colors.white), child: Text( 'Sign Up', style: TextStyle( color: Colors.blue, fontSize: 12, fontWeight: FontWeight.w500), ), )) ], ), ), ), // amazing flutter login and registration source code emailField(), passwordField(), !isLoginSelected ? SizedBox() : forgotPassword(), isLoginSelected ? SizedBox() : confirmPasswordField(), !isLoginSelected ? SizedBox( height: 40, ) : SizedBox(), button(), ], ), ), ), ), ); } // Beautiful flutter login and registration source code template screen ui design Widget emailField() { return Padding( padding: const EdgeInsets.symmetric(horizontal: 60).copyWith(top: 10), child: Container( alignment: Alignment.centerLeft, padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10), height: 50, width: double.infinity, decoration: BoxDecoration(boxShadow: [ BoxShadow( offset: Offset(4, 4), blurRadius: 5, spreadRadius: 0, color: Colors.grey.shade400) ], borderRadius: BorderRadius.circular(50), color: Colors.white), child: TextField( style: TextStyle(color: Colors.black54, fontSize: 14), decoration: InputDecoration( border: InputBorder.none, prefixIconConstraints: BoxConstraints(minWidth: 24), prefixIcon: Padding( padding: EdgeInsets.only(right: 10), child: Icon( Icons.email, color: Colors.black45, size: 20, ), ), hintText: 'Enter email', hintStyle: TextStyle(color: Colors.black45, fontSize: 14), ), ), )); } // flutter login and registration source code Widget passwordField() { return Padding( padding: const EdgeInsets.symmetric(horizontal: 60).copyWith(top: 15), child: Container( alignment: Alignment.centerLeft, padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10), height: 50, width: double.infinity, decoration: BoxDecoration(boxShadow: [ BoxShadow( offset: Offset(4, 4), blurRadius: 5, spreadRadius: 0, color: Colors.grey.shade400) ], borderRadius: BorderRadius.circular(50), color: Colors.white), child: TextField( obscureText: showPassword ? false : true, style: TextStyle(color: Colors.black54, fontSize: 14), decoration: InputDecoration( border: InputBorder.none, suffixIconConstraints: BoxConstraints(minWidth: 24), prefixIconConstraints: BoxConstraints(minWidth: 24), prefixIcon: Padding( padding: EdgeInsets.only(right: 10), child: Icon( Icons.lock, color: Colors.black45, size: 20, ), ), suffixIcon: Padding( padding: EdgeInsets.only(left: 10), child: GestureDetector( onTap: () { setState(() { showPassword = !showPassword; }); }, child: Icon( showPassword ? Icons.visibility : Icons.visibility_off, color: Colors.black45, size: 20, ), ), ), hintText: 'Enter password', hintStyle: TextStyle(color: Colors.black45, fontSize: 14), ), ), )); } Widget confirmPasswordField() { return Padding( padding: const EdgeInsets.symmetric(horizontal: 60).copyWith(top: 15), child: Container( alignment: Alignment.centerLeft, padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10), height: 50, width: double.infinity, decoration: BoxDecoration(boxShadow: [ BoxShadow( offset: Offset(4, 4), blurRadius: 5, spreadRadius: 0, color: Colors.grey.shade400) ], borderRadius: BorderRadius.circular(50), color: Colors.white), child: TextField( obscureText: showConfirmPassword ? false : true, style: TextStyle(color: Colors.black54, fontSize: 14), decoration: InputDecoration( border: InputBorder.none, suffixIconConstraints: BoxConstraints(minWidth: 24), prefixIconConstraints: BoxConstraints(minWidth: 24), prefixIcon: Padding( padding: EdgeInsets.only(right: 10), child: Icon( Icons.lock, color: Colors.black45, size: 20, ), ), suffixIcon: Padding( padding: EdgeInsets.only(left: 10), child: GestureDetector( onTap: () { setState(() { showConfirmPassword = !showConfirmPassword; }); }, child: Icon( showConfirmPassword ? Icons.visibility : Icons.visibility_off, color: Colors.black45, size: 20, ), ), ), hintText: 'Confirm password', hintStyle: TextStyle(color: Colors.black45, fontSize: 14), ), ), )); } // flutter login and registration source code Widget forgotPassword() { return Align( alignment: Alignment.centerRight, child: Padding( padding: const EdgeInsets.only(top: 10, right: 58, bottom: 30), child: InkWell( onTap: () { // can navigate to other screen or perform some other action }, child: Text( 'Forgot password?', style: TextStyle( color: Colors.blue, fontSize: 12, fontWeight: FontWeight.w700), ), ), ), ); } // flutter login and registration source code Widget button() { return GestureDetector( onTap: () { ScaffoldMessenger.of(context) .showSnackBar(SnackBar(content: Text('Clicked'))); }, child: Container( alignment: Alignment.center, margin: EdgeInsets.symmetric(horizontal: 60).copyWith(bottom: 15), height: 50, width: double.infinity, decoration: BoxDecoration(boxShadow: [ BoxShadow( offset: Offset(4, 4), blurRadius: 5, spreadRadius: 0, color: Colors.grey.shade400) ], borderRadius: BorderRadius.circular(50), color: Colors.white), child: Text( isLoginSelected ? 'Sign In' : 'Register', style: TextStyle( color: Colors.blue, fontSize: 14, fontWeight: FontWeight.w700), ), ), ); } }
Conclusion
To conclude this tutorial, hope you now have a complete and in-depth practical knowledge of how to create this beautiful Flutter login and registration template design. I’d be looking forward to have your feedback on this post.
I’d also love to see you visit my other tutorials on Flutter app development and Python programming as well. Thank you for reading this post.
You might also like:
Beautiful Flutter Login And Registration UI Design [Free Source Code]
How To Set Flutter OutlinedButton Rounded Corners [Easy Flutter Guide]
How To Easily Use Flutter Appbar Tabs [Easy Flutter Guide]
How To Change Flutter OutlinedButton Border Radius [Flutter Easy Guide]
How To Change Flutter OutlinedButton Background Color
Beautiful Flutter Login And Registration Screen UI Design [Free Source Code]
How To Change Flutter OutlinedButton Elevation [Easy Flutter Guide]