Skip to content

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¦ text_field_custom

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.


✨ Features

  • βœ… 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

πŸ“Έ Preview

Add screenshots or GIFs from /example for better engagement.


πŸš€ Installation

Add this to your pubspec.yaml:

dependencies:
  text_field_custom: ^2.0.0

Then run:

flutter pub get

πŸ“¦ Import

import 'package:text_field_custom/text_field_custom.dart';
import 'package:text_field_custom/text_field_custom_theme.dart';

🧠 Theming (NEW πŸš€)

You can now configure global styles using ThemeExtension.

πŸ”₯ Setup in main.dart

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,
        ),
      ),
    ],
  ),
);

πŸŒ™ Dark Theme Support

darkTheme: ThemeData(
  brightness: Brightness.dark,
  extensions: [
    TextFieldCustomTheme(
      fillColor: Colors.grey.shade900,
      textStyle: TextStyle(color: Colors.white),
      hintStyle: TextStyle(color: Colors.grey),
    ),
  ],
),

🎯 Styling Priority

Widget parameter > ThemeExtension > Default values

This gives you full flexibility + global consistency.


🧱 Basic Usage

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;
  },
)

🧩 Usage Examples


1️⃣ Simple Field

TextFieldCustom(
  title: "Name",
  hintText: "Enter your name",
)

2️⃣ Password Field

TextFieldCustom(
  title: "Password",
  hintText: "Enter password",
  obscureText: true,
)

3️⃣ Phone Field with Formatter

TextFieldCustom(
  title: "Phone",
  keyboardType: TextInputType.phone,
  maxLength: 10,
  inputFormatters: [FilteringTextInputFormatter.digitsOnly],
)

4️⃣ Read-only Picker Field

TextFieldCustom(
  title: "Date of Birth",
  hintText: "Select date",
  readOnly: true,
  onTap: () {
    // Open date picker
  },
)

5️⃣ With Prefix & Suffix

TextFieldCustom(
  title: "Search",
  hintText: "Search",
  prefix: Icon(Icons.search),
  suffix: Icon(Icons.mic),
)

6️⃣ Multiline Text Field

TextFieldCustom(
  title: "Description",
  maxLines: 4,
)

7️⃣ Filled Style Field

TextFieldCustom(
  title: "Username",
  filled: true,
  fillColor: Colors.grey.shade100,
  border: OutlineInputBorder(
    borderRadius: BorderRadius.circular(12),
  ),
)

8️⃣ Disabled / View-only Field

TextFieldCustom(
  title: "User ID",
  initialValue: "USR_12345",
  onlyText: true,
)

9️⃣ Override Global Theme Locally

TextFieldCustom(
  title: "Custom Field",
  filled: false,
  border: UnderlineInputBorder(),
)

πŸ§ͺ Example App

A complete working example is available in:

/example

Run it:

cd example
flutter run

🧩 Available Parameters

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

πŸ—οΈ Why use this package?

  • πŸš€ Reduces repetitive UI code
  • 🎯 Standardizes form UI across apps
  • 🎨 Centralized theming support
  • 🧼 Clean and scalable architecture
  • πŸ“¦ Easy to maintain and extend

πŸ›£οΈ Roadmap

  • Field variants (outlined / filled / borderless)
  • Size system (small / medium / large)
  • Built-in password toggle
  • SearchField / DateField variants
  • Form builder helpers

🀝 Contributing

Contributions, issues, and feature requests are welcome!


πŸ§‘β€πŸ’» Author

Amarjeet Srivastava Senior Flutter Developer


πŸ“„ License

MIT License

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages