Flutter OTP Screen UI Example – OTP TextField Code

Flutter, Flutter Login App, Flutter UI / UX, UI UX

In this flutter UI tutorial, we will learn how to design a beautiful modern and minimal Flutter OTP Screen UI. To design this OTP screen we will use Flutter OTP TextField.

There are two mainly used Flutter OTP Packages and dependencies on pub.dev.

  1. flutter_otp_text_field
  2. otp_text_field

Among all these, we will use flutter otp text field package (first one).

We will also learn how to get single box value from OTP and also whole OTP entered by the user.

In our previous tutorials, we already learned how to design Flutter Login, Signup, Forget Password and Welcome Screen UI. So, In this tutorial, I will explain the OTP Screen UI for Signup, Forget Password including Email and Phone No.

You can watch recent playlist tutorials and all the related tutorials to this Tutorial.

Watch Youtube tutorial

 

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

@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
padding: const EdgeInsets.all(tDefaultSize),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
tOtpTitle,
style: GoogleFonts.montserrat(fontWeight: FontWeight.bold, fontSize: 80.0),
),
Text(tOtpSubTitle.toUpperCase(), style: Theme.of(context).textTheme.headline6),
const SizedBox(height: 40.0),
const Text("$tOtpMessage support@codingwitht.com", textAlign: TextAlign.center),
const SizedBox(height: 20.0),
OtpTextField(
mainAxisAlignment: MainAxisAlignment.center,
numberOfFields: 6,
fillColor: Colors.black.withOpacity(0.1),
filled: true,
onSubmit: (code) => print("OTP is => $code")),
const SizedBox(height: 20.0),
SizedBox(
width: double.infinity,
child: ElevatedButton(onPressed: () {}, child: const Text(tNext)),
),
],
),
),
);
}
}

CODING with T

🚀 Supercharge your Flutter skills! Subscribe to my YouTube channel now for mind-blowing coding insights, expert tips, and exclusive content. Don’t miss out!

Best Laptops for Developers 2024 Top Picks & Reviews

Source code

COURSES

Flutter E Commerce App Modern and latest
Flutter Login App UI Source Code - Flutter Complete App - Flutter App Design - Flutter App 2023 - Complete Flutter App 2023
Learn flutter from scratch in 4 hours - Flutter Crash Course - Coding with T

Learn Flutter

1.2 # How to install flutter on android studio 2022 - Flutter Basic Crash Course
2.2 - Add Image in Flutter - Assets Network- Flutter Basic Crash Course 2022

flutter Design

How to create a Custom Shape in Flutter. Flutter E Commerce app Design. Ecommerce app design Flutter. Flutter clippath tutorial
How to create a Custom Appbar in flutter. Custom Appbar Design. Flutter App Design
16 - Product Card and Grid Layout, How to create a Grid View in Flutter. How to add Products in GridView Layout. Flutter eCommerce app UI Design
Bottom Navigation bar in Flutter. Flutter Material 3 bottom navigation bar. How to design background color of Flutter bottom navigation bar. Flutter ecommerce app design
23 - Product Detail Screen, How to create Products Details Screen in Flutter. Flutter eCommerce app UI Design

Flutter Backend

33 - How to Setup Firebase - Firebase Basics - Flutter Firebase - Flutter ecommerce app with firebase as backend
38 - How to Sign-in with Google in flutter Firebase, Firebase Basics, Flutter Firebase, Flutter ecommerce app with firebase as backend
40 - Flutter Firebase CRUD,  Firebase Basics, Flutter Firebase, Flutter ecommerce app with firebase as backend