A highly customizable, reusable, and production-ready Flutter text field widget with built-in support for titles, validation, theming, borders, icons, formatting, and more.
Designed to reduce boilerplate, ensure UI consistency, and accelerate form development across Flutter apps.
- β Optional title with required indicator (*)
- β Built-in validation support
- β Prefix & suffix widget support
- β Read-only, disabled & view-only modes
- β Filled, outlined & custom border styles
- β Input formatters, maxLength, multiline support
- β Keyboard actions & focus control
- β π Dark & Light theme support (ThemeExtension)
- β π¨ Global styling via ThemeData
- β β‘ Clean, scalable & production-ready API
Add screenshots or GIFs from
/examplefor better engagement.
Add this to your pubspec.yaml:
dependencies:
text_field_custom: ^2.0.0Then run:
flutter pub getimport 'package:text_field_custom/text_field_custom.dart';
import 'package:text_field_custom/text_field_custom_theme.dart';You can now configure global styles using ThemeExtension.
MaterialApp(
theme: ThemeData(
extensions: [
TextFieldCustomTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
fillColor: Color(0xFFF5F5F5),
filled: true,
textStyle: TextStyle(fontSize: 14),
hintStyle: TextStyle(color: Colors.grey),
titleStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 14,
),
),
],
),
);darkTheme: ThemeData(
brightness: Brightness.dark,
extensions: [
TextFieldCustomTheme(
fillColor: Colors.grey.shade900,
textStyle: TextStyle(color: Colors.white),
hintStyle: TextStyle(color: Colors.grey),
),
],
),Widget parameter > ThemeExtension > Default values
This gives you full flexibility + global consistency.
TextFieldCustom(
title: "Email",
hintText: "Enter your email",
isRequired: true,
validator: (v) {
if (v == null || v.isEmpty) return "Email is required";
if (!v.contains("@")) return "Invalid email";
return null;
},
)TextFieldCustom(
title: "Name",
hintText: "Enter your name",
)TextFieldCustom(
title: "Password",
hintText: "Enter password",
obscureText: true,
)TextFieldCustom(
title: "Phone",
keyboardType: TextInputType.phone,
maxLength: 10,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
)TextFieldCustom(
title: "Date of Birth",
hintText: "Select date",
readOnly: true,
onTap: () {
// Open date picker
},
)TextFieldCustom(
title: "Search",
hintText: "Search",
prefix: Icon(Icons.search),
suffix: Icon(Icons.mic),
)TextFieldCustom(
title: "Description",
maxLines: 4,
)TextFieldCustom(
title: "Username",
filled: true,
fillColor: Colors.grey.shade100,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
),
)TextFieldCustom(
title: "User ID",
initialValue: "USR_12345",
onlyText: true,
)TextFieldCustom(
title: "Custom Field",
filled: false,
border: UnderlineInputBorder(),
)A complete working example is available in:
/example
Run it:
cd example
flutter run| Parameter | Description |
|---|---|
title |
Label shown above field |
hintText |
Placeholder text |
controller |
TextEditingController |
validator |
Validation function |
obscureText |
Password mode |
readOnly |
Makes field readonly |
enabled |
Enables / disables field |
onlyText |
View-only mode |
prefix |
Prefix widget |
suffix |
Suffix widget |
filled |
Filled background |
fillColor |
Background color |
border |
Custom border |
keyboardType |
Keyboard type |
textInputAction |
Keyboard action |
maxLines |
Multiline support |
maxLength |
Character limit |
inputFormatters |
Input formatters |
onChanged |
Change callback |
onSubmitted |
Submit callback |
- π Reduces repetitive UI code
- π― Standardizes form UI across apps
- π¨ Centralized theming support
- π§Ό Clean and scalable architecture
- π¦ Easy to maintain and extend
- Field variants (outlined / filled / borderless)
- Size system (small / medium / large)
- Built-in password toggle
- SearchField / DateField variants
- Form builder helpers
Contributions, issues, and feature requests are welcome!
Amarjeet Srivastava Senior Flutter Developer
MIT License