form_builder_extra_fields 8.3.0 icon indicating copy to clipboard operation
form_builder_extra_fields: ^8.3.0 copied to clipboard

Additional ready-made form input fields for flutter_form_builder package


import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:form_builder_extra_fields/form_builder_extra_fields.dart';
import 'package:form_builder_validators/form_builder_validators.dart';

void main() {
  runApp(const MyApp());

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

  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch:,
      localizationsDelegates: const [
      supportedLocales: FormBuilderLocalizations.delegate.supportedLocales,
      home: const MyHomePage(),

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  final _formKey = GlobalKey<FormBuilderState>();

  void _onChanged(dynamic val) => debugPrint(val.toString());

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Extra Fields Example')),
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: FormBuilder(
            key: _formKey,
            onChanged: () {
            autovalidateMode: AutovalidateMode.onUserInteraction,
            child: Column(
              children: [
                  popupProps: const true),
                  name: 'searchable_dropdown_online',
                  onChanged: _onChanged,
                  asyncItems: (filter) async {
                    await Future.delayed(const Duration(seconds: 1));
                    return allCountries
                        .where((element) => element
                  decoration: const InputDecoration(
                    labelText: 'Searchable Dropdown Online',
                  popupProps: const true),
                  dropdownSearchDecoration: const InputDecoration(
                    hintText: 'Search',
                    labelText: 'Search',
                  name: 'searchable_dropdown_offline',
                  items: allCountries,
                  onChanged: _onChanged,
                  decoration: const InputDecoration(
                      labelText: 'Searchable Dropdown Offline'),
                  filterFn: (country, filter) =>
                const SizedBox(height: 15),
                  name: 'color_picker',
                  initialValue: Colors.yellow,
                  // readOnly: true,
                  colorPickerType: ColorPickerType.materialPicker,
                  decoration: const InputDecoration(labelText: 'Color Picker'),
                  decoration: const InputDecoration(labelText: 'Chips Input'),
                  name: 'chips_test',
                  onChanged: _onChanged,
                  maxChips: 5,
                  findSuggestions: (String query) {
                    if (query.isNotEmpty) {
                      var lowercaseQuery = query.toLowerCase();
                      return contacts.where((profile) {
                                .contains(query.toLowerCase()) ||
                      }).toList(growable: false)
                        ..sort((a, b) =>
                    } else {
                      return const <Contact>[];
                  chipBuilder: (context, state, profile) {
                    return InputChip(
                      key: ObjectKey(profile),
                      label: Text(,
                      avatar: CircleAvatar(
                        backgroundImage: NetworkImage(profile.imageUrl),
                      onDeleted: () => state.deleteChip(profile),
                      materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                  suggestionBuilder: (context, state, profile) {
                    return ListTile(
                      key: ObjectKey(profile),
                      leading: CircleAvatar(
                        backgroundImage: NetworkImage(profile.imageUrl),
                      title: Text(,
                      subtitle: Text(,
                      onTap: () => state.selectSuggestion(profile),
                  name: 'date_time',
                  inputType: CupertinoDateTimePickerInputType.both,
                  decoration: const InputDecoration(
                    labelText: 'Cupertino DateTime Picker',
                  locale: const Locale.fromSubtags(languageCode: 'en_GB'),
                  name: 'date',
                  decoration: const InputDecoration(
                    labelText: 'Cupertino DateTime Picker - Date Only',
                  locale: const Locale.fromSubtags(languageCode: 'en_GB'),
                  name: 'time',
                  inputType: CupertinoDateTimePickerInputType.time,
                  decoration: const InputDecoration(
                    labelText: 'Cupertino DateTime Picker - Time Only',
                  locale: const Locale.fromSubtags(languageCode: 'en_GB'),
                  decoration: const InputDecoration(
                    labelText: 'TypeAhead (Autocomplete TextField)',
                    hintText: 'Start typing country name',
                  name: 'country',
                  onChanged: _onChanged,
                  itemBuilder: (context, country) {
                    return ListTile(title: Text(country));
                  controller: TextEditingController(text: ''),
                  initialValue: 'Uganda',
                  suggestionsCallback: (query) {
                    if (query.isNotEmpty) {
                      var lowercaseQuery = query.toLowerCase();
                      return allCountries.where((country) {
                        return country.toLowerCase().contains(lowercaseQuery);
                      }).toList(growable: false)
                        ..sort((a, b) => a
                    } else {
                      return allCountries;
                  decoration: const InputDecoration(labelText: 'TouchSpin'),
                  name: 'touch_spin',
                  initialValue: 10,
                  step: 1,
                  iconSize: 48.0,
                  addIcon: const Icon(Icons.arrow_right),
                  subtractIcon: const Icon(Icons.arrow_left),
                  onChanged: _onChanged,
                  decoration: const InputDecoration(labelText: 'Rating Bar'),
                  name: 'rate',
                  // enabled: false,
                  itemSize: 32.0,
                  initialValue: 1.0,
                  maxRating: 5.0,
                  onChanged: _onChanged,
                  decoration: const InputDecoration(
                    labelText: 'Signature Pad',
                  name: 'signature',
                  border: Border.all(color:,
                  onChanged: _onChanged,
                const SizedBox(height: 10),
                  children: <Widget>[
                      child: MaterialButton(
                        color: Theme.of(context).colorScheme.secondary,
                        onPressed: () {
                          if (_formKey.currentState?.saveAndValidate() ??
                              false) {
                          } else {
                            debugPrint('validation failed');
                        child: const Text(
                          style: TextStyle(color: Colors.white),
                    const SizedBox(width: 20),
                      child: OutlinedButton(
                        onPressed: () {
                        // color: Theme.of(context).colorScheme.secondary,
                        child: Text(
                          style: TextStyle(
                              color: Theme.of(context).colorScheme.secondary),

class Contact {
  final String name;
  final String email;
  final String imageUrl;

  const Contact(,, this.imageUrl);

  bool operator ==(Object other) =>
      identical(this, other) ||
      other is Contact &&
          runtimeType == other.runtimeType &&
          name ==;

  int get hashCode => name.hashCode;

  String toString() {
    return name;

const allCountries = [
  'American Samoa',
  'Antigua and Barbuda',
  'Bosnia and Herzegowina',
  'Bouvet Island',
  'British Indian Ocean Territory',
  'Brunei Darussalam',
  'Burkina Faso',
  'Cape Verde',
  'Cayman Islands',
  'Central African Republic',
  'Christmas Island',
  'Cocos (Keeling) Islands',
  'Congo, the Democratic Republic of the',
  'Cook Islands',
  'Costa Rica',
  'Cote d\'Ivoire',
  'Croatia (Hrvatska)',
  'Czech Republic',
  'Dominican Republic',
  'East Timor',
  'El Salvador',
  'Equatorial Guinea',
  'Falkland Islands (Malvinas)',
  'Faroe Islands',
  'France Metropolitan',
  'French Guiana',
  'French Polynesia',
  'French Southern Territories',
  'Heard and Mc Donald Islands',
  'Holy See (Vatican City State)',
  'Hong Kong',
  'Iran (Islamic Republic of)',
  'Korea, Democratic People\'s Republic of',
  'Korea, Republic of',
  'Lao, People\'s Democratic Republic',
  'Libyan Arab Jamahiriya',
  'Macedonia, The Former Yugoslav Republic of',
  'Marshall Islands',
  'Micronesia, Federated States of',
  'Moldova, Republic of',
  'Netherlands Antilles',
  'New Caledonia',
  'New Zealand',
  'Norfolk Island',
  'Northern Mariana Islands',
  'Papua New Guinea',
  'Puerto Rico',
  'Russian Federation',
  'Saint Kitts and Nevis',
  'Saint Lucia',
  'Saint Vincent and the Grenadines',
  'San Marino',
  'Sao Tome and Principe',
  'Saudi Arabia',
  'Sierra Leone',
  'Slovakia (Slovak Republic)',
  'Solomon Islands',
  'South Africa',
  'South Georgia and the South Sandwich Islands',
  'Sri Lanka',
  'St. Helena',
  'St. Pierre and Miquelon',
  'Svalbard and Jan Mayen Islands',
  'Syrian Arab Republic',
  'Taiwan, Province of China',
  'Tanzania, United Republic of',
  'Trinidad and Tobago',
  'Turks and Caicos Islands',
  'United Arab Emirates',
  'United Kingdom',
  'United States',
  'United States Minor Outlying Islands',
  'Virgin Islands (British)',
  'Virgin Islands (U.S.)',
  'Wallis and Futuna Islands',
  'Western Sahara',

const contacts = <Contact>[
  Contact('Andrew', '',
  Contact('Paul', '',
  Contact('Fred', '',
  Contact('Brian', '',
  Contact('John', '',
  Contact('Thomas', '',
  Contact('Nelly', '',
  Contact('Marie', '',
  Contact('Charlie', '',
  Contact('Diana', '',
  Contact('Ernie', '',
  Contact('Gina', '',