forme 2.0.0-alpha3 copy "forme: ^2.0.0-alpha3" to clipboard
forme: ^2.0.0-alpha3 copied to clipboard

outdated

flutter row-column based form builder, build form quickly,create field fast,less code,more powerful

Forme #

a powerful flutter form widget

Simple Usage #

FormeKey formKey = FormeKey(); // FormeKey is a GlobalKey, used to get  a FormeManagement
Forme(key:formKey,
	readOnly:true|false,
	onChanged:FormeValueChanged,
	child:Widget child,
	);

Form Field #

Form Field types #

FormeField
	- StatefulField
		- ValueField
			- NonnullValueField
		- CommonField

attributes supported by all StatefulFields #

attribute type description
name String? name of a field ,used to control field and get error
builder FormContentBuilder used to build field widget
model AbstractFormeModel used to determine how to build a field widget
readOnly bool whether field should be readOnly

ValueField #

supported attributes

attribute type description
validator FormFieldValidator? validator
autovalidateMode AutovalidateMode?
initialValue T?
enabled bool
onSaved FormFieldSetter? called when save form

NonnullValueField #

supported attributes

attribute type description
validator NonnullFieldValidator? validator
autovalidateMode AutovalidateMode?
initialValue T
enabled bool
onSaved NonnullFormFieldSetter? called when save form

methods #

FormeManagement #

get FormeManagement

FormeManagement formeManagement = formKey.currentFormeManagement;// return a nonnull FormeManagement
FormeManagement? formeManagement = formKey.quietlyManagement;// return a FormeManagement , return null if not find

check whether form has a name field

bool hasField = formeManagement.hasField(String name);

whether form is readOnly

bool readOnly = formeManagement.readOnly;

set form readOnly|editable

formeManagement.readOnly = true|false;

get form data

Map<String, dynamic> data = formeManagement.data;

get form field validate errors

List<FormeFieldManagementWithError> errors = formeManagement.errors;

quietly vaidate form

List<FormeFieldManagementWithError> errors = formeManagement.quietlyValidate();

set form data

formeManagement.data = data;// will trigger field's onChanged listener
formeManagement.setData(data,trigger:bool) // if trigger is false ,won't trigger field's onChanged listener

reset form

formeManagement.reset();

validate form

will display error text

bool isValid = formeManagement.validate();

whether form is valid

won't display error text

bool isValid = formeManagement.isValid;

save form

formeManagement.save();

FormeFieldManagement #

create FormeFieldManagement by name

FormeFieldManagement formeFieldManagement = formeManagement.newFormeFieldManagement(String name);

get field's name

String? name = formeFieldManagement.name;

whether field is readOnly

bool readOnly = formeFieldManagement.readOnly;

set readOnly|editable on field

formeFieldManagement.readOnly = true|false;

whether field is focusable

bool focusable = formeFieldManagement.focusable;

whether field is focused

bool hasFocus = formeFieldManagement.hasFocus;

focus|unfocus a form field

formeFieldManagement.focus = true|false;

set focus listener on field

formeFieldManagement.focusListener = (key,hasFocus){};

whether field is a value field

bool isValueField = formeFieldManagement.isValueField;

whether field support TextSelection

bool supportTextSelection = formeFieldManagement.supportTextSelection;

set state model

formeFieldManagement.model = AbstractFormeModel();

get state model

AbstractFormeModel model = formeFieldManagement.model;

ensure form field visible

formeFieldManagement.ensureVisible();

FormeValueFieldManagement #

get FormeValueFieldManagement

if field is not a value field , an error will be throw

FormeValueFieldManagement valueFieldManagement = formeFieldManagement.valueFieldManagement;

get field's value

dynamic value = valueFieldManagement.value;

set field value

valueFieldManagement.value = value; // set field value , will trigger onChanged listener
textSelectionManagement.setValue(value,trigger:bool); // if trigger is false ,won't trigger onChanged listener

whether field is valid

won't display error text

bool isValid = valueFieldManagement.isValid;

validate field

will display error text

bool isValid = valueFieldManagement.validate();

get error text

String? errorText = valueFieldManagement.errorText;

quietlyValidate field

won't display error text

String? errorText = valueFieldManagement.quietlyValidate();

currently supported value fields #

field return value nullable
FormeTextField string false
FormeDateTime DateTime true
FormeSelector List< T> false
FormeListTile List< T> false
FormeNumberTextField num true
FormeSlider double false
FormeRangeSlider RangeValues false
FormeFilterChip List< T> false
FormeChoiceChip T true
FormeRate dobule true
FormeSingleCheckbox bool false
FormeSingleSwitch bool false
FormeCupertinoPicker int false

currently supported other fields #

field description
FormeButton button
FormeVisible make field visible|invisible
FormeColumn a column support insert|swap|remove widgets
FormeRow a row support insert|swap|remove widgets

example for helping build a custom field #

build a common field #

https://github.com/wwwqyhme/flutter-form-builder/blob/main/lib/src/field/forme_button.dart

build a nonnull value field #

https://github.com/wwwqyhme/flutter-form-builder/blob/main/lib/src/field/forme_single_switch.dart

build a value field #

https://github.com/wwwqyhme/flutter-form-builder/blob/main/lib/src/field/forme_rate.dart

25
likes
0
points
278
downloads

Publisher

verified publisherqyh.me

Weekly Downloads

flutter row-column based form builder, build form quickly,create field fast,less code,more powerful

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on forme