form_flutter 0.0.1 copy "form_flutter: ^0.0.1" to clipboard
form_flutter: ^0.0.1 copied to clipboard

A Flutter package for reusable forms, validators, and field catalogs.

form_flutter #

A Flutter package for building reusable, schema-friendly forms with shared validation, common field widgets, and preset field catalogs.

Features #

  • Reusable form controller for values, errors, and async validation state
  • Common field widgets for text, password, multiline, number, dropdown, radio, checkbox, switch, date, time, date-time, slider, and multi-select
  • Sync and async validators for text, numbers, dates, files, conditional rules, and uniqueness checks
  • Preset field catalog for personal, contact, address, account, academic, professional, survey, commerce, appointment, and consent flows
  • Common option sets for fields like gender, marital status, degree, employment type, payment method, and more

Getting started #

Add the package to your pubspec.yaml:

dependencies:
  form_flutter: ^1.0.0

Then run:

flutter pub get

Usage #

Import the package:

import 'package:form_flutter/form_flutter.dart';

Create a controller and define your fields:

final controller = FormFlutterController(
  initialValues: const {
    'fullName': '',
    'email': '',
    'acceptTerms': false,
  },
);

final fields = <FormFlutterField<dynamic>>[
  FormFlutterTextField(
    name: 'fullName',
    label: 'Full name',
    validator: FormFlutterValidators.combine([
      FormFlutterValidators.requiredText(),
      FormFlutterValidators.minLength(3),
    ]),
  ),
  FormFlutterTextField(
    name: 'email',
    label: 'Email',
    keyboardType: TextInputType.emailAddress,
    validator: FormFlutterValidators.combine([
      FormFlutterValidators.requiredText(),
      FormFlutterValidators.email(),
    ]),
    asyncValidator: FormFlutterValidators.uniqueEmail(
      (email, _) async => email != 'taken@example.com',
    ),
  ),
  FormFlutterCheckboxField(
    name: 'acceptTerms',
    label: 'I agree to the Terms and Conditions',
    validator: FormFlutterValidators.mustBeTrue(),
  ),
];

Render them with DynamicFormFlutter:

DynamicFormFlutter(
  controller: controller,
  fields: fields,
  submitLabel: 'Submit',
  onSubmit: (values) {
    debugPrint('Submitted: ${values.asMap()}');
  },
)

Validators #

Available validator helpers include:

  • requiredText, requiredNumber, requiredSelection, requiredDate, requiredTime, requiredValue
  • email, phone, url, numericText, pattern
  • minLength, maxLength, exactLength
  • minNumber, maxNumber
  • minDate, maxDate, minimumAge
  • sameAsField, requiredIf, conditional
  • minItems, maxItems
  • requiredFile, fileSize, fileExtension, imageOnly
  • strongPassword, mediumPassword, highStrengthPassword
  • uniqueValue, uniqueUsername, uniqueEmail
  • combine, combineAsync, custom

Preset catalog #

form_flutter includes metadata presets and option sets to help build real-world forms faster.

Examples:

  • FormFlutterCatalog.personalInformation
  • FormFlutterCatalog.contactInformation
  • FormFlutterCatalog.addressInformation
  • FormFlutterCatalog.accountFields
  • FormFlutterCatalog.professionalFields
  • FormFlutterCatalog.appointmentFields
  • FormFlutterCatalog.consentFields

Examples of shared option sets:

  • FormFlutterOptionSets.gender
  • FormFlutterOptionSets.maritalStatus
  • FormFlutterOptionSets.degrees
  • FormFlutterOptionSets.employmentTypes
  • FormFlutterOptionSets.paymentMethods

Additional information #

This repository currently still includes a demo app in lib/main.dart to exercise the package API locally. A future cleanup step is to move that demo into an example/ app for publishing.

0
likes
0
points
199
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for reusable forms, validators, and field catalogs.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cupertino_icons, flutter

More

Packages that depend on form_flutter