Flutter Fast Forms는 Flutter 폼 생성을 간소화하기 위해 설계된 Dart 패키지로, 개발자가 빠르게 강력하고 재사용 가능한 폼 컴포넌트를 만들 수 있도록 도와줍니다. 최소한의 반복 코드로 폼 필드, 검증 규칙 및 제출 로직을 정의할 수 있는 간단하고 선언적인 API를 제공합니다. Android, iOS, Web, macOS, Windows, Linux 등 주요 플랫폼을 모두 지원하여 크로스플랫폼 애플리케이션에 이상적입니다. 일반적인 입력 유형과 사용자 정의 가능한 검증기 기능을 내장하고 있어 유연성과 성능을 희생하지 않고 개발 속도를 높일 수 있습니다.
사용 사례
빠른 형상 프로토타이핑
크로스 플랫폼 폼 개발
복잡한 검증 워크플로
재사용 가능한 폼 컴포넌트
간소화된 사용자 등록 흐름
주요 기능
선언적 폼 구문
내장 검증 보조 함수
크로스 플랫폼 호환성
확장 가능한 필드 유형
최소한의 보일러플레이트 코드
적합한 대상
초보자용 Flutter 개발자
속도를 우선시하는 팀
동적 폼이 필요한 앱
엄격한 마감일이 있는 프로젝트
양식의 복잡성에서 벗어나는 개발자
고려 사항
기본 위젯 외의 사용자 정의가 제한적
새로운 DSL 유사 구문을 배워야 할 수 있습니다
매우 고유한 폼 레이아웃에는 적합하지 않음
패키지 유지보수에 의존
표준 양식 패턴에 가장 적합
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Flutter Fast Forms
Flutter Fast Forms is the only Dart package you need to build Flutter forms fast.
It adds these missing features to the Flutter SDK:
Not all controls in a form are autonomous and act independent of each other.
Occasionally, the state of a form field might be directly related to the state of some other form field as well.
Flutter Fast Forms allows you to define such conditions declaratively.
📓 Example: A FastTextField that is disabled when a FastSwitch is selected.
1. Add the conditions property to the conditional form field and assign an empty Map:
constFastSwitch(
name: 'switch',
titleText: 'Disable text field',
),
FastTextField(
name: 'text_field',
labelText: 'Just some sample text field',
conditions: {},
),
2. Choose a suitable FastConditionHandler as Map key and assign a FastConditionList:
constFastSwitch(
name: 'switch',
titleText: 'Disable text field when selected',
),
FastTextField(
name: 'text_field',
labelText: 'Just some sample text field',
conditions: {
FastCondition.disabled: FastConditionList([]),
},
)
[!NOTE]
A FastConditionHandler is a function that runs whenever a FastConditionList is checked and determines what happens when the condition is either met or not.
3. Add a FastCondition relating the field to another field:
constFastSwitch(
name: 'switch',
titleText: 'Disable text field when selected',
),
FastTextField(
name: 'text_field',
labelText: 'Just some sample text field',
conditions: {
FastCondition.disabled: FastConditionList([
FastCondition(
target: 'switch',
test: (value, field) => value isbool && value,
),
]),
},
),
[!NOTE]
target is the name of the FastFormField that the form field depends on.
📓 Example: A FastTextField that is enabled when a FastSwitchor a FastCheckbox is selected.
constFastCheckbox(
name: 'checkbox',
titleText: 'Enable text field when selected',
),
constFastSwitch(
name: 'switch',
titleText: 'Enable text field when selected',
),
FastTextField(
name: 'text_field',
enabled: false,
labelText: 'Just some sample text field',
conditions: {
FastCondition.enabled: FastConditionList([
FastCondition(
target: 'switch',
test: (value, field) => value isbool && value,
),
FastCondition(
target: 'checkbox',
test: (value, field) => value isbool && value,
),
]),
},
),
📓 Example: A FastTextField that is disabled when both a FastSwitchand a FastCheckbox are selected.
constFastCheckbox(
name: 'checkbox',
titleText: 'Disable text field when selected',
),
constFastSwitch(
name: 'switch',
titleText: 'Disable text field when selected',
),
FastTextField(
name: 'text_field',
labelText: 'Just some sample text field',
conditions: {
FastCondition.enabled: FastConditionList(
[
FastCondition(
target: 'switch',
test: (value, field) => value isbool && value,
),
FastCondition(
target: 'checkbox',
test: (value, field) => value isbool && value,
),
],
match: FastConditionMatch.every,
),
},
),
[!NOTE]
match specifies how all individual test results in the list are evaluated to determine whether the condition is met.
Custom Form Fields
There are use cases where the widget catalog does not fully satisfy your individual requirements.
As a consequence you have to add non-standard controls to your form.
With Flutter Fast Forms you're free to wrap any custom widget into a form field.
📓 Example: A simple widget that provides a random integer whenever a button is pressed.
1. Create a stateful widget class extending FastFormField<T> with a corresponding FastFormFieldState<T>:
[!NOTE]
Always make sure that you apply certain super-initializer parameters like decoration or enabled in your builder functions.
Otherwise assigning those arguments when invoking the constructor won't have any effect.