Skip to content

Quick Start

Build a complete Course Enrollment form in 5 minutes using the FormBuilder DSL.

The Scenario

We will create an LMS enrollment form that:

  1. Collects student name, email, and phone number
  2. Lets the student select a course and enrollment type
  3. Shows payment fields only when "Paid Enrollment" is selected
  4. Validates all inputs with appropriate rules
  5. Groups preferences into a collapsible section
  1. Import the DSL

    The DSL import gives you FormBuilder, all field builders, and the When class for conditional rules.

  2. Build the Form

    Chain field builders fluently — starting a new field auto-finalizes the previous one, so no .done() calls are needed.

    enrollment_form.dart
  3. Use the Form

    The build() method returns a Form object with a fully wired FormGroup. You can render it or work with it programmatically.

  4. Render in Flutter

    Use the form's content builder system to render it. The default vertical layout renders fields in order; explicit side-by-side layout uses row blocks.

    enrollment_page.dart

What You Built

In under 50 lines of DSL code, you created a form with:

  • 6 fields across 3 types (text, select, date)
  • Validation -- required, email, min length
  • Conditional visibility -- payment method appears only for paid enrollment
  • Sequential layout -- fields render in the order declared by the DSL
  • Collapsible section -- preferences grouped and collapsible
  • Reactive state -- FormGroup-backed values with MobX observability

Key Patterns

PatternHow
Auto-finalizeStarting a new field commits the previous one -- no .done() needed
Fluent validation.required().email().minLength(2) chains naturally
Conditional rules.showWhen(When.fieldEquals(...)) for declarative visibility
RowsUse FormRowBlock in the runtime model or Row blocks in the visual editor for side-by-side fields
Sections.section('Title', (s) => s.field(...)) for visual grouping

Next Steps