{"id":13552455,"url":"https://github.com/flutter-form-builder-ecosystem/flutter_form_builder","last_synced_at":"2025-05-13T19:16:11.292Z","repository":{"id":37336764,"uuid":"155439350","full_name":"flutter-form-builder-ecosystem/flutter_form_builder","owner":"flutter-form-builder-ecosystem","description":"Simple form maker for Flutter Framework","archived":false,"fork":false,"pushed_at":"2025-05-02T09:31:03.000Z","size":84810,"stargazers_count":1548,"open_issues_count":54,"forks_count":551,"subscribers_count":22,"default_branch":"main","last_synced_at":"2025-05-12T07:52:47.672Z","etag":null,"topics":["dart","dartlang","flutter","flutter-form-builder","flutter-package","form-validation","forms"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/flutter_form_builder","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flutter-form-builder-ecosystem.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"flutter-form-builder-ecosystem"}},"created_at":"2018-10-30T18:49:20.000Z","updated_at":"2025-05-07T04:32:57.000Z","dependencies_parsed_at":"2023-11-08T12:04:03.514Z","dependency_job_id":"13afc005-be96-4cc1-831d-6c7d38a359c6","html_url":"https://github.com/flutter-form-builder-ecosystem/flutter_form_builder","commit_stats":{"total_commits":1319,"total_committers":133,"mean_commits":9.917293233082706,"dds":"0.43138741470811226","last_synced_commit":"3cd4f18cd87c17806984c08c14d16006640f23d5"},"previous_names":["danvick/flutter_form_builder"],"tags_count":149,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flutter-form-builder-ecosystem%2Fflutter_form_builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flutter-form-builder-ecosystem%2Fflutter_form_builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flutter-form-builder-ecosystem%2Fflutter_form_builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flutter-form-builder-ecosystem%2Fflutter_form_builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flutter-form-builder-ecosystem","download_url":"https://codeload.github.com/flutter-form-builder-ecosystem/flutter_form_builder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254010823,"owners_count":21999003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","dartlang","flutter","flutter-form-builder","flutter-package","form-validation","forms"],"created_at":"2024-08-01T12:02:04.268Z","updated_at":"2025-05-13T19:16:11.243Z","avatar_url":"https://github.com/flutter-form-builder-ecosystem.png","language":"Dart","funding_links":["https://opencollective.com/flutter-form-builder-ecosystem"],"categories":["Dart"],"sub_categories":[],"readme":"# Flutter Form Builder\n\nThis 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.\n\nAlso 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.\n\n[![Pub Version](https://img.shields.io/pub/v/flutter_form_builder?logo=flutter\u0026style=for-the-badge)](https://pub.dev/packages/flutter_form_builder)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/flutter-form-builder-ecosystem/flutter_form_builder/base.yaml?branch=main\u0026logo=github\u0026style=for-the-badge)](https://github.com/flutter-form-builder-ecosystem/flutter_form_builder/actions/workflows/base.yaml)\n[![Codecov](https://img.shields.io/codecov/c/github/flutter-form-builder-ecosystem/flutter_form_builder?logo=codecov\u0026style=for-the-badge)](https://codecov.io/gh/flutter-form-builder-ecosystem/flutter_form_builder/)\n[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/flutter-form-builder-ecosystem/flutter_form_builder?logo=codefactor\u0026style=for-the-badge)](https://www.codefactor.io/repository/github/flutter-form-builder-ecosystem/flutter_form_builder)\n\n---\n\n## Call for Maintainers\n\n\u003e We are looking for maintainers to contribute to the development and maintenance of Flutter Form Builder Ecosystem. Is very important to keep the project alive and growing, so we need your help to keep it up to date and with new features. You can contribute in many ways, we describe some of them in [Support](#support) section.\n\n- [Features](#features)\n- [Inputs](#inputs)\n  - [Parameters](#parameters)\n- [Use](#use)\n  - [Setup](#setup)\n  - [Basic use](#basic-use)\n  - [Specific uses](#specific-uses)\n    - [Validate and get values](#validate-and-get-values)\n    - [Building your own custom field](#building-your-own-custom-field)\n    - [Programmatically changing field value](#programmatically-changing-field-value)\n    - [Programmatically inducing an error](#programmatically-inducing-an-error)\n    - [Conditional validation](#conditional-validation)\n    - [Implement reset, clear or other button into field](#implement-reset-clear-or-other-button-into-field)\n- [Support](#support)\n  - [Contribute](#contribute)\n  - [Questions and answers](#questions-and-answers)\n  - [Donations](#donations)\n- [Roadmap](#roadmap)\n- [Ecosystem](#ecosystem)\n- [Thanks to](#thanks-to)\n\n## Features\n\n- Create a form with several type of inputs\n- Get values from form by easy way\n- Apply validators to inputs fields\n- React to form fields changes and validations\n\n| Complete Form                                                                                                                                                 | Sign Up                                                                                                                                             | Dynamic Fields                                                                                                                                                | Conditional Form                                                                                                                                                      |\n| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| ![Gif demostration with all fields](https://raw.githubusercontent.com/flutter-form-builder-ecosystem/flutter_form_builder/main/screenshots/complete_form.gif) | ![Gif demostration sign up form](https://raw.githubusercontent.com/flutter-form-builder-ecosystem/flutter_form_builder/main/screenshots/signup.gif) | ![Gif demostration dynamic fields](https://raw.githubusercontent.com/flutter-form-builder-ecosystem/flutter_form_builder/main/screenshots/dynamic_fields.gif) | ![Gif demostration conditional fields](https://raw.githubusercontent.com/flutter-form-builder-ecosystem/flutter_form_builder/main/screenshots/conditional_fields.gif) |\n\n## Inputs\n\nThe currently supported fields include:\n\n- `FormBuilderCheckbox` - Single checkbox field\n- `FormBuilderCheckboxGroup` - List of checkboxes for multiple selection\n- `FormBuilderChoiceChip` - Creates a chip that acts like a radio button.\n- `FormBuilderDateRangePicker` - For selection of a range of dates\n- `FormBuilderDateTimePicker` - For `Date`, `Time` and `DateTime` input\n- `FormBuilderDropdown` - Used to select one value from a list as a Dropdown\n- `FormBuilderFilterChip` - Creates a chip that acts like a checkbox\n- `FormBuilderRadioGroup` - Used to select one value from a list of Radio Widgets\n- `FormBuilderRangeSlider` - Used to select a range from a range of values\n- `FormBuilderSlider` - For selection of a numerical value on a slider\n- `FormBuilderSwitch` - On/Off switch field\n- `FormBuilderTextField` - A Material Design text field input\n\n### Parameters\n\nIn 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:\n\n| Attribute          | Type                    | Default             | Required | Description                                                                                                                               |\n| ------------------ | ----------------------- | ------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------- |\n| `name`             | `String`                |                     | `Yes`    | This will form the key in the form value Map                                                                                              |\n| `initialValue`     | `T`                     | `null`              | `No`     | The initial value of the input field                                                                                                      |\n| `enabled`          | `bool`                  | `true`              | `No`     | Determines whether the field widget will accept user input.                                                                               |\n| `decoration`       | `InputDecoration`       | `InputDecoration()` | `No`     | Defines the border, labels, icons, and styles used to decorate the field.                                                                 |\n| `validator`        | `FormFieldValidator\u003cT\u003e` | `null`              | `No`     | A `FormFieldValidator` that will check the validity of value in the `FormField`                                                           |\n| `onChanged`        | `ValueChanged\u003cT\u003e`       | `null`              | `No`     | This event function will fire immediately the the field value changes                                                                     |\n| `valueTransformer` | `ValueTransformer\u003cT\u003e`   | `null`              | `No`     | Function that transforms field value before saving to form value. e.g. transform TextField value for numeric field from `String` to `num` |\n\nThe rest of the attributes will be determined by the type of Widget being used.\n\n## Use\n\n### Setup\n\nNo specific setup required: only install the dependency and use :)\n\n### Basic use\n\n```dart\nfinal _formKey = GlobalKey\u003cFormBuilderState\u003e();\n\nFormBuilder(\n    key: _formKey,\n    child:  FormBuilderTextField(\n        name: 'text',\n        onChanged: (val) {\n            print(val); // Print the text value write into TextField\n        },\n    ),\n)\n```\n\nSee [pub.dev example tab](https://pub.dev/packages/flutter_form_builder/example) or [github code](example/lib/main.dart) for more details\n\n### Specific uses\n\n#### Validate and get values\n\nNote: Validators are in a separate package\n([form_builder_validators](https://pub.dev/packages/form_builder_validators)).\n\n```dart\nfinal _formKey = GlobalKey\u003cFormBuilderState\u003e();\n\nFormBuilder(\n  key: _formKey,\n  child: Column(\n    children: [\n      FormBuilderTextField(\n        key: _emailFieldKey,\n        name: 'email',\n        decoration: const InputDecoration(labelText: 'Email'),\n        validator: FormBuilderValidators.compose([\n          FormBuilderValidators.required(),\n          FormBuilderValidators.email(),\n        ]),\n      ),\n      const SizedBox(height: 10),\n      FormBuilderTextField(\n        name: 'password',\n        decoration: const InputDecoration(labelText: 'Password'),\n        obscureText: true,\n        validator: FormBuilderValidators.compose([\n          FormBuilderValidators.required(),\n        ]),\n      ),\n      MaterialButton(\n        color: Theme.of(context).colorScheme.secondary,\n        onPressed: () {\n          // Validate and save the form values\n          _formKey.currentState?.saveAndValidate();\n          debugPrint(_formKey.currentState?.value.toString());\n\n          // On another side, can access all field values without saving form with instantValues\n          _formKey.currentState?.validate();\n          debugPrint(_formKey.currentState?.instantValue.toString());\n        },\n        child: const Text('Login'),\n      )\n    ],\n  ),\n),\n```\n\n#### Building your own custom field\n\nTo build your own field within a `FormBuilder`, we use `FormBuilderField` which will require that you define your own field.\nRead [this article](https://medium.com/@danvickmiller/building-a-custom-flutter-form-builder-field-c67e2b2a27f4) for step-by-step instructions on how to build your own custom field.\n\n```dart\nvar options = [\"Option 1\", \"Option 2\", \"Option 3\"];\n```\n\n```dart\nFormBuilderField(\n  name: \"name\",\n  validator: FormBuilderValidators.compose([\n    FormBuilderValidators.required(),\n  ]),\n  builder: (FormFieldState\u003cdynamic\u003e field) {\n    return InputDecorator(\n      decoration: InputDecoration(\n        labelText: \"Select option\",\n        contentPadding:\n            EdgeInsets.only(top: 10.0, bottom: 0.0),\n        border: InputBorder.none,\n        errorText: field.errorText,\n      ),\n      child: Container(\n        height: 200,\n        child: CupertinoPicker(\n          itemExtent: 30,\n          children: options.map((c) =\u003e Text(c)).toList(),\n          onSelectedItemChanged: (index) {\n            field.didChange(options[index]);\n          },\n        ),\n      ),\n    );\n  },\n),\n```\n\n#### Programmatically changing field value\n\nYou can either change the value of one field at a time like so:\n\n```dart\n_formKey.currentState.fields['color_picker'].didChange(Colors.black);\n```\n\nOr multiple fields value like so:\n\n```dart\n_formKey.currentState.patchValue({\n  'age': '50',\n  'slider': 6.7,\n  'filter_chip': ['Test 1'],\n  'choice_chip': 'Test 2',\n  'rate': 4,\n  'chips_test': [\n    Contact(\n        'Andrew',\n        'stock@man.com',\n        'https://d2gg9evh47fn9z.cloudfront.net/800px_COLOURBOX4057996.jpg',\n    ),\n  ],\n});\n```\n\n#### Programmatically inducing an error\n\n##### Using form state key or field state key\n\n```dart\nfinal _formKey = GlobalKey\u003cFormBuilderState\u003e();\nfinal _emailFieldKey = GlobalKey\u003cFormBuilderFieldState\u003e();\n...\nFormBuilder(\n  key: _formKey,\n  child: Column(\n    children: [\n      FormBuilderTextField(\n        key: _emailFieldKey,\n        name: 'email',\n        decoration: const InputDecoration(labelText: 'Email'),\n        validator: FormBuilderValidators.compose([\n          FormBuilderValidators.required(),\n          FormBuilderValidators.email(),\n        ]),\n      ),\n      ElevatedButton(\n        child: const Text('Submit'),\n        onPressed: () async {\n          if(await checkIfEmailExists()){\n            // Either invalidate using Form Key\n            _formKey.currentState?.fields['email']?.invalidate('Email already taken');\n            // OR invalidate using Field Key\n            _emailFieldKey.currentState?.invalidate('Email already taken');\n          }\n        },\n      ),\n    ],\n  ),\n),\n```\n\nWhen use `invalidate` and `validate` methods, can use two optional parameters configure the behavior\nwhen invalidate field or form, like focus or auto scroll. Take a look on method documentation for more details\n\n##### Using InputDecoration.errorText\n\nDeclare a variable to hold your error:\n\n```dart\nString _emailError;\n```\n\nUse the variable as the `errorText` within `InputDecoration`\n\n```dart\nFormBuilderTextField(\n  name: 'email',\n  decoration: InputDecoration(\n    labelText: 'Email',\n    errorText: _emailError,\n  ),\n  validator: FormBuilderValidators.compose([\n      FormBuilderValidators.required(),\n      FormBuilderValidators.email(),\n  ]),\n),\n```\n\nSet the error text\n\n```dart\nElevatedButton(\n  child: Text('Submit'),\n  onPressed: () async {\n    setState(() =\u003e _emailError = null);\n    if(await checkIfEmailExists()){\n      setState(() =\u003e _emailError = 'Email already taken.');\n    }\n  },\n),\n```\n\n#### Conditional validation\n\nYou can also validate a field based on the value of another field\n\n```dart\nFormBuilderRadioGroup(\n  decoration: InputDecoration(labelText: 'My best language'),\n  name: 'my_language',\n  validator: FormBuilderValidators.required(),\n  options: [\n    'Dart',\n    'Kotlin',\n    'Java',\n    'Swift',\n    'Objective-C',\n    'Other'\n  ]\n    .map((lang) =\u003e FormBuilderFieldOption(value: lang))\n    .toList(growable: false),\n  ),\n  FormBuilderTextField(\n    name: 'specify',\n    decoration:\n        InputDecoration(labelText: 'If Other, please specify'),\n    validator: (val) {\n      if (_formKey.currentState.fields['my_language']?.value ==\n              'Other' \u0026\u0026\n          (val == null || val.isEmpty)) {\n        return 'Kindly specify your language';\n      }\n      return null;\n    },\n  ),\n```\n\n#### Implement reset, clear or other button into field\n\nIf you can add some button to reset specific field, can use the `decoration` parameter like this:\n\n```dart\nList\u003cString\u003e genderOptions = ['Male', 'Female', 'Other'];\n\nFormBuilderDropdown\u003cString\u003e(\n  name: 'gender',\n  initialValue: 'Male',\n  decoration: InputDecoration(\n    labelText: 'Gender',\n    suffix: IconButton(\n      icon: const Icon(Icons.close),\n      onPressed: () {\n        _formKey.currentState!.fields['gender']\n            ?.reset();\n      },\n    ),\n    hintText: 'Select Gender',\n  ),\n  items: genderOptions\n      .map((gender) =\u003e DropdownMenuItem(\n            alignment: AlignmentDirectional.center,\n            value: gender,\n            child: Text(gender),\n          ))\n      .toList(),\n),\n```\n\nOr reset value like this:\n\n```dart\nclass ClearFormBuilderTextField extends StatefulWidget {\n  const ClearFormBuilderTextField({super.key});\n\n  @override\n  State\u003cClearFormBuilderTextField\u003e createState() =\u003e\n      _ClearFormBuilderTextFieldState();\n}\n\nclass _ClearFormBuilderTextFieldState\n    extends State\u003cClearFormBuilderTextField\u003e {\n  final ValueNotifier\u003cString?\u003e text = ValueNotifier\u003cString?\u003e(null);\n  final textFieldKey = GlobalKey\u003cFormBuilderFieldState\u003e();\n\n  @override\n  Widget build(BuildContext context) {\n    return FormBuilderTextField(\n      autovalidateMode: AutovalidateMode.always,\n      name: 'age',\n      key: textFieldKey,\n      onChanged: (value) {\n        text.value = value;\n      },\n      decoration: InputDecoration(\n        labelText: 'Age',\n        suffixIcon: ValueListenableBuilder\u003cString?\u003e(\n          valueListenable: text,\n          child: IconButton(\n            onPressed: () =\u003e textFieldKey.currentState?.didChange(null),\n            tooltip: 'Clear',\n            icon: const Icon(Icons.clear),\n          ),\n          builder: (context, value, child) =\u003e\n              (value?.isEmpty ?? true) ? const SizedBox() : child!,\n        ),\n      ),\n    );\n  }\n}\n```\n\n## Migrations\n\n### v9 to v10\n\n- Remove `invalidateField` and `invalidateFirstField` methods from FormBuilderState. Use `fields[name]?.invalidate(errorText)` and `fields.first.invalidate(errorText)` instead\n- [FormBuilderTextField] Deprecate canRequestFocus property. Use `FocusNode.canRequestFocus.` instead\n- Assert on FormBuilderField.decoration.enabled property. Use FormBuilderField.enabled instead\n- Easy way! Only need execute `dart fix --apply` on your project to fix the following changes:\n  - Rename FormBuilderChoiceChip to FormBuilderChoiceChips.\n  - Rename FormBuilderFilterChip to FormBuilderFilterChips.\n  - [FormBuilderFilterChip] Remove maxChips property.\n  - [FormBuilderDateTimePicker] Remove resetIcon property.\n  - [FormBuilder] Remove onPopInvoked property.\n\n## Support\n\n### Contribute\n\nYou have some ways to contribute to this packages\n\n- Beginner: Reporting bugs or request new features\n- Intermediate: Implement new features (from issues or not) and created pull requests\n- Advanced: Join to [organization](#ecosystem) like a member and help coding, manage issues, dicuss new features and other things\n\nSee [contribution file](https://github.com/flutter-form-builder-ecosystem/.github/blob/main/CONTRIBUTING.md) for more details\n\n### Questions and answers\n\nYou can question or search answers on [Github discussion](https://github.com/flutter-form-builder-ecosystem/flutter_form_builder/discussions) or on [StackOverflow](https://stackoverflow.com/questions/tagged/flutter-form-builder)\n\n### Donations\n\nDonate or become a sponsor of Flutter Form Builder Ecosystem\n\n[![Become a Sponsor](https://opencollective.com/flutter-form-builder-ecosystem/tiers/sponsor.svg?avatarHeight=56)](https://opencollective.com/flutter-form-builder-ecosystem)\n\n## Roadmap\n\n- [Solve open issues](https://github.com/flutter-form-builder-ecosystem/flutter_form_builder/issues), [prioritizing bugs](https://github.com/flutter-form-builder-ecosystem/flutter_form_builder/labels/bug)\n\n## Ecosystem\n\nTake a look to [our awesome ecosystem](https://github.com/flutter-form-builder-ecosystem) and all packages in there\n\n## Thanks to\n\n[All contributors](https://github.com/flutter-form-builder-ecosystem/flutter_form_builder/graphs/contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflutter-form-builder-ecosystem%2Fflutter_form_builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflutter-form-builder-ecosystem%2Fflutter_form_builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflutter-form-builder-ecosystem%2Fflutter_form_builder/lists"}