formstack library

FormStack - A dynamic form and survey builder for Flutter.

Build forms from Dart objects or JSON with 28 input types, 30+ validators, conditional navigation, nested steps, and customizable styling.

Quick Start

import 'package:formstack/formstack.dart';

FormStack.api().form(steps: [
  QuestionStep(
    title: "Your Name",
    inputType: InputType.name,
    id: GenericIdentifier(id: "name"),
  ),
  CompletionStep(
    title: "Done!",
    id: GenericIdentifier(id: "done"),
    onFinish: (result) => print(result),
  ),
]);

// In your widget build method:
Scaffold(body: FormStack.api().render());

See the README for full documentation.

Classes

AudioRecorder
Records audio from the device microphone.
AudioRecording
A completed audio recording.
BarcodeScanner
Scans a barcode or QR code using the device camera.
BaseStepView<T extends FormStep>
Base class of all step views including any components. Abstract class with basic component methods required for form navigation and validation.
CompletionStep
The final step of a form.
ConsentSection
A single section within a ConsentStep document.
ConsentStep
A structured consent document step with visual section walkthrough.
DateResultType
Validator requiring a DateTime, carrying the format used to render it.
DeviceCapabilities
Device capabilities FormStack can use when an application provides them.
DisplayStep
A read-only step that presents content rather than collecting an answer.
DynamicConditionalRelevant
A RelevantCondition that uses a custom callback function.
DynamicData
Data item for InstructionStep instructions list or DisplayStep data.
ExpressionLanguage
A cross-field validation document.
ExpressionObject
One clause of an ExpressionLanguage document: a step id and the expression its answer must satisfy.
ExpressionRelevant
A RelevantCondition that evaluates an expression string against the result.
ExpressionValidator
Evaluates an ExpressionLanguage document against collected results.
ExternalDataProvider
Provides options from an external data source (CSV, API, database).
FormDraft
Serializable form draft containing all step results and metadata.
FormIdentifier
Identifier for a form instance.
FormPersistence
Abstract interface for persisting form state.
FormProgress
An immutable snapshot of how far through a form the user is.
FormStack
FormStack - Comprehensive Library for Creating Dynamic Form
FormStackForm
Abstract base class managing form state, step navigation, and result collection.
FormStackLocale
Multi-language support for FormStack forms.
FormStackTheme
Centralized sizing configuration for FormStack forms.
FormStackThemeScope
Provides a FormStackTheme to the forms rendered beneath it.
FormStep
Base class for all form steps.
FormStepView<T extends FormStep>
The view for one FormStep.
FormWizard
The concrete FormStackForm created by FormStack.api().form(...).
GenericIdentifier
General-purpose identifier with an explicit id.
HexColor
Parses hex color strings (e.g., "#FF5722", "#AABBCC") into Color objects.
Identifier
Base class for step and form identifiers.
InMemoryFormPersistence
In-memory implementation of FormPersistence for testing and simple use cases.
InputBuildContext
Everything a custom input widget needs in order to build itself.
InputRegistry
Maps input-type names to the widgets that render them.
InstructionStep
An informational step: a title, body text and optional media, with no input to collect.
JsonReader
Typed accessors for the JSON maps that form definitions are parsed from.
KeyValue
A key-value pair used with InputType.dynamicKeyValue.
LocationWrapper
Wrapper for latitude/longitude coordinates.
MapKey
Google Maps API keys for each platform.
MapWidget
A map viewport, resolved to the mobile or web implementation at compile time by conditional import.
NestedStep
A step that shows several questions on one screen.
Options
A selectable option used in choice-based inputs.
ParserUtils
Translates JSON form definitions into FormStep graphs.
PopStep
A step that pops the enclosing route instead of rendering anything.
QuestionStep
A step that asks the user for one answer.
RelevantCondition
Base class for conditional navigation between form steps.
RepeatStep
A step that renders its child steps N times dynamically.
ResultFormat
Validation format for form step results.
ReviewStep
A step that displays all collected form results for review before submission.
StaticDataProvider
Loads options from a static list of maps (simulates CSV/JSON data).
StepIdentifier
Auto-generated identifier for a form step.
StepRegistry
Maps the JSON "type" discriminator to the step it constructs.
StepResult
Result data from a single form step.
TaskResult
Aggregated result from an entire form/task run.
UIStyle
Visual styling configuration for form steps and input fields.
ValidationResult
The outcome of validating a single step result.
ValidatorRegistry
Resolves validators by name so forms defined in JSON can use the full ResultFormat library — and so applications can contribute their own.

Enums

ComponentsStyle
Visual style of list-based components (choices, tiles).
ConsentSectionType
Predefined consent section types (modeled after Apple ResearchKit).
Display
Controls the text size of step titles and descriptions.
DisplayStepType
What a DisplayStep renders.
InputStyle
Visual style of text input fields.
InputType
All supported input types for QuestionStep.
SelectionType
Display style for choice selection indicators.

Extensions

EmailValidator on String
String predicates backing the built-in validators.
IBANValidator on String
IBAN checksum validation, separated so it can be reused independently.

Functions

cast<T>(dynamic x) → T?
Safely casts x to type T, returning null if the cast fails.

Typedefs

DefaultValidatorBuilder = ResultFormat Function()
Supplies the validator used when a step does not declare its own.
InputViewBuilder = FormStepView<FormStep> Function(InputBuildContext context)
Builds the view for one input type.
OnBeforeFinishCallback = Future<bool> Function(Map<String, dynamic> result)
Runs just before a form completes, for a final async step such as posting the results. The returned future is awaited before navigation.
ResultFormatFactory = ResultFormat Function(String message, Map<String, dynamic> args)
Builds a ResultFormat from its JSON description.
StepFactory = FormStep Function(Map<String, dynamic> json, List<RelevantCondition> relevantConditions)
Builds a FormStep from its JSON description.