flutter_form_builder 7.6.0 icon indicating copy to clipboard operation
flutter_form_builder: ^7.6.0 copied to clipboard

This package helps in creation of forms in Flutter by removing the boilerplate code, reusing validation, react to changes, and collect final user input.

Flutter Form Builder #

This package helps in creation of data collection forms in Flutter by removing the boilerplate needed to build a form, validate fields, react to changes and collect final user input.

Also included are common ready-made form input fields for FormBuilder. This gives you a convenient way of adding common ready-made input fields instead of creating your own FormBuilderField from scratch.

Pub Version GitHub Workflow Status Codecov CodeFactor Grade Discord

Features #

  • Create a form with several type of inputs
  • Get values from form by easy way
  • Apply validators to inputs fields
  • React to form fields changes and validations

Inputs #

The currently supported fields include:

  • FormBuilderCheckbox - Single checkbox field
  • FormBuilderCheckboxGroup - List of checkboxes for multiple selection
  • FormBuilderChoiceChip - Creates a chip that acts like a radio button.
  • FormBuilderDateRangePicker - For selection of a range of dates
  • FormBuilderDateTimePicker - For Date, Time and DateTime input
  • FormBuilderDropdown - Used to select one value from a list as a Dropdown
  • FormBuilderFilterChip - Creates a chip that acts like a checkbox
  • FormBuilderRadioGroup - Used to select one value from a list of Radio Widgets
  • FormBuilderRangeSlider - Used to select a range from a range of values
  • FormBuilderSegmentedControl - For selection of a value using the CupertinoSegmentedControl widget as an input
  • FormBuilderSlider - For selection of a numerical value on a slider
  • FormBuilderSwitch - On/Off switch field
  • FormBuilderTextField - A Material Design text field input

Parameters #

In order to create an input field in the form, along with the label, and any applicable validation, there are several attributes that are supported by all types of inputs namely:

nameStringYesThis will form the key in the form value Map
initialValueTnullNoThe initial value of the input field
enabledbooltrueNoDetermines whether the field widget will accept user input.
decorationInputDecorationInputDecoration()NoDefines the border, labels, icons, and styles used to decorate the field.
validatorFormFieldValidator<T>nullNoA FormFieldValidator that will check the validity of value in the FormField
onChangedValueChanged<T>nullNoThis event function will fire immediately the the field value changes
valueTransformerValueTransformer<T>nullNoFunction that transforms field value before saving to form value. e.g. transform TextField value for numeric field from String to num
The rest of the attributes will be determined by the type of Widget being used.

Use #

Setup #

No especific setup required: only install the dependency and use :)

Basic use #

final _formKey = GlobalKey<FormBuilderState>();

    key: _formKey,
    child:  FormBuilderTextField(
        name: 'text',
        onChanged: (val) {
            print(val); // Print the text value write into TextField

See pud.dev example tab or github code for more details

Especific uses #

Building your own custom field

To build your own field within a FormBuilder, we use FormBuilderField which will require that you define your own field. Read this article for step-by-step instructions on how to build your own custom field.

var options = ["Option 1", "Option 2", "Option 3"];
  name: "name",
  validator: FormBuilderValidators.compose([
# Flutter Form Builder
  builder: (FormFieldState<dynamic> field) {
    return InputDecorator(
      decoration: InputDecoration(
        labelText: "Select option",
            EdgeInsets.only(top: 10.0, bottom: 0.0),
        border: InputBorder.none,
        errorText: field.errorText,
      child: Container(
        height: 200,
        child: CupertinoPicker(
          itemExtent: 30,
          children: options.map((c) => Text(c)).toList(),
          onSelectedItemChanged: (index) {

Programmatically changing field value

You can either change the value of one field at a time like so:


Or multiple fields value like so:

  'age': '50',
  'slider': 6.7,
  'filter_chip': ['Test 1'],
  'choice_chip': 'Test 2',
  'rate': 4,
  'chips_test': [

Programmatically inducing an error

Option 1 - Using FormBuilder / FieldBuilderField key
final _formKey = GlobalKey<FormBuilderState>();
final _emailFieldKey = GlobalKey<FormBuilderFieldState>();
  key: _formKey,
  child: Column(
    children: [
        key: _emailFieldKey,
        name: 'email',
        decoration: const InputDecoration(labelText: 'Email'),
        validator: FormBuilderValidators.compose([
        child: const Text('Submit'),
        onPressed: () async {
          if(await checkIfEmailExists()){
            // Either invalidate using Form Key
                name: 'email', errorText: 'Email already taken.');
            // OR invalidate using Field Key
                ?.invalidate('Email already taken');
Option 2 - Using InputDecoration.errorText

Declare a variable to hold your error:

String _emailError;

Use the variable as the errorText within InputDecoration

  name: 'email',
  decoration: InputDecoration(
    labelText: 'Email',
    errorText: _emailError,
  validator: FormBuilderValidators.compose([

Set the error text

  child: Text('Submit'),
  onPressed: () async {
    setState(() => _emailError = null);
    if(await checkIfEmailExists()){
      setState(() => _emailError = 'Email already taken.');

Conditional validation

You can also validate a field based on the value of another field

  decoration: InputDecoration(labelText: 'My best language'),
  name: 'my_language',
  validator: FormBuilderValidators.required(),
  options: [
    .map((lang) => FormBuilderFieldOption(value: lang))
    .toList(growable: false),
    name: 'specify',
        InputDecoration(labelText: 'If Other, please specify'),
    validator: (val) {
      if (_formKey.currentState.fields['my_language']?.value ==
              'Other' &&
          (val == null || val.isEmpty)) {
        return 'Kindly specify your language';
      return null;

Implement reset, clear or other button into FormBuilderField

If you can add some button to reset specific field, can use the decoration parameter like this:

List<String> genderOptions = ['Male', 'Female', 'Other'];

  name: 'gender',
  decoration: InputDecoration(
    labelText: 'Gender',
    initialValue: 'Male',
    suffix: IconButton(
      icon: const Icon(Icons.close),
      onPressed: () {
    hintText: 'Select Gender',
  items: genderOptions
      .map((gender) => DropdownMenuItem(
            alignment: AlignmentDirectional.center,
            value: gender,
            child: Text(gender),

Or if is allowed by the field, set a value like this:

  name: 'age',
  decoration: InputDecoration(
    labelText: 'Age',
    suffixIcon: IconButton(
      icon: const Icon(Icons.plus_one),
      onPressed: () {
  initialValue: '13',
  keyboardType: TextInputType.number,

Support #

Contribute #

You have some ways to contribute to this packages

  • Beginner: Reporting bugs or request new features
  • Intermediate: Implement new features (from issues or not) and created pull requests
  • Advanced: Join to organization like a member and help coding, manage issues, dicuss new features and other things

See contribution file for more details

Questions and answers #

You can join to our Discord server or search answers in StackOverflow

Donations #

Buy a coffe to Danvick Miller, creator of this awesome package

Buy me a coffee

Roadmap #

Ecosystem #

Take a look to our awesome ecosystem and all packages in there

Thanks to #

Contributors #

Made with contrib.rocks.

pub points


verified publisher iconflutterformbuilderecosystem.com

This package helps in creation of forms in Flutter by removing the boilerplate code, reusing validation, react to changes, and collect final user input.

Repository (GitHub)
View/report issues


API reference


Icon for licenses.BSD-3-Clause (LICENSE)


collection, flutter, intl


Packages that depend on flutter_form_builder