form_builder 0.0.2 form_builder: ^0.0.2 copied to clipboard
flutter form builder, used to quickly build a row-column based form ,null safetty and no dependencies required! support :textfield|numberfield|slider|rangeSlider|datetimefield|selector|checkboxgroup|radiogroup
flutter_form_builder #
basic usage #
FormManagement formManagement = FormManagement();
Widget form = FormBuilder(
{bool readOnly,//set form's readonly state
bool visible, // set form's visible state
FormThemeData formThemeData, //set themedata of form
FormManagement formManagement,
FormInitCallback initCallback})
.textField(
controlKey:'username',//control key is optional,used to control form field and hold state
labelText: 'username',
clearable: true,
flex: 3,
validator: (value) => value.isEmpty ? 'can not be empty !' : null,
);
FormManagement #
check whether form is initialled or not #
bool initialled = formManagement.initialled;
check whether form is visible or not #
bool visible = formManagement.visible;
hide|show form #
formManagement.visible = true|false;
check whether form is readOnly or not #
bool readOnly = formManagement.readOnly;
set form readonly|editable #
formManagement.readOnly = true|false;
get current form themedata #
FormThemeData formThemeData = formManagement.formThemeData;
set form theme #
formManagement.formThemeData = FormThemeData(themeData);// system theme
formManagement.formThemeData = DefaultFormTheme(); //default theme from https://github.com/mitesh77/Best-Flutter-UI-Templates/blob/master/best_flutter_ui_templates/lib/hotel_booking/filters_screen.dart
get form data #
formManagement.data; // auto remove null
formManagement.getData({bool removeNull = false});
reset form #
formManagement.reset();
validate form #
formManagement.validate();
check whether form is valid or not #
unlike validate method,this method won't display error msg
formManagement.isValid
check whether form has a controlKey or not #
bool exists = formManagement.hasControlKey(String controlKey);
get FormFieldManagement #
FormFieldManagement formFieldManagement = formManagement.getFormFieldManagement(String controlKey)
get FormLayoutManagement #
FormLayoutManagement formLayoutManagement = formManagement.formLayoutManagement;
get FormWidgetTreeManagement #
FormWidgetTreeManagement formWidgetTreeManagement = formManagement.formWidgetTreeManagement
FormFieldManagement #
check whether a field is ValueField or not #
bool isValueField = formFieldManagement.isValueField;
check whether a field is readOnly or not #
bool readOnly = formFieldManagement.readOnly;
set readOnly on formFieldManagement #
formFieldManagement.readOnly = true|false
check whether a field is removed or not #
bool removed = formFieldManagement.removed;
remove|unremove a form field #
formFieldManagement.remove = true|false
check whether a field is visible or not #
bool visible = formFieldManagement.visible;
set visible on form field #
formFieldManagement.visible = true|false
set autovalidateMode on value field #
formFieldManagement.autovalidateMode = AutovalidateMode;
set initialValue on value field #
formFieldManagement.initialValue = value;
validate a value field #
bool isValid = formFieldManagement.validate();
check whether a value field is valid or not #
unlike validate method,this method won't display error msg
bool isValid = formFieldManagement.isValid;
reset value field #
formFieldManagement.reset();
get padding of a form field #
EdgeInsets padding = formFieldManagement.padding;
set padding of a form field #
formFieldManagement.padding = padding;
check whether a value field is focused or not #
bool hasFocus = formFieldManagement.focus;
focus|unfocus a form field #
formFieldManagement.focus = true|false
get value of a value field #
dynamic value = formFieldManagement.value;
set value on a value field #
formFieldManagement.setValue(dynamic value,{bool trigger = true});
trigger whether trigger field's onChange callback or not
rebuild a form field's state #
formFieldManagement.state = {};
update a form field's state #
formFieldManagement.update({});
remove form field's states #
formFieldManagement.removeState(Set<String> keys);
get TextSelectionManagement #
TextSelectionManagement textSelectionManagement = formFieldManagement.textSelectionManagement;
only textfield|numberfield support this method!
get SubController #
SubControllerDelegate subController = formFieldManagement.subController;
only checkboxGroup|switchGroup|radiogroup support this method
set focuslistener on a form field` #
formFieldManagement.focusListener = FocusListener();
you should call this method in FormBuilder's initCallback
FormLayoutManagement #
get rows of a form #
int rows = formLayoutManagement.rows;
get FormLayoutRowManagement #
FormLayoutRowManagement formLayoutRowManagement = formLayoutManagement.getFormLayoutRowManagement(int row);
get FormFieldManagement #
FormFieldManagement formFieldManagement = formLayoutManagement.getFormFieldManagement(int row,int column);
FormLayoutRowManagement #
get columns of a row #
int columns = formLayoutRowManagement.columns;
check whether a row is visible or not #
bool visible = formLayoutRowManagement.visible;
set visiable on a row #
formLayoutRowManagement.visible = true|false;
set readOnly on a row #
formLayoutRowManagement.readOnly = true|false;
remove|unremove a row #
formLayoutRowManagement.remove = true|false;
FormWidgetTreeManagement #
check whether a layout is editing or not #
bool isEditing = formWidgetTreeManagement.isEditing;
get rows of currrent editing layout #
int rows = formWidgetTreeManagement.rows;
get columns of a row in current editing layout #
int columns = formWidgetTreeManagement.getColumns(int row);
remove a field in widget tree #
formWidgetTreeManagement.remove(String controlKey);
remove a row|field in widget tree #
formWidgetTreeManagement.removeAtPosition(int row,{int column});
insert a row at position #
void insert(
{int column,
int row,
String controlKey,
int flex = 1,
bool visible = true,
EdgeInsets padding,
@required Widget field,
bool inline = true,
bool insertRow = false})
swap two rows #
formWidgetTreeManagement.swapRow(int oldRow, int newRow)
start edit current layout #
formWidgetTreeManagement.startEdit();
apply edited layout #
formWidgetTreeManagement.apply();
cancel editing layout #
formWidgetTreeManagement.cancel();
currently support field #
field | return value | nullable |
---|---|---|
TextField | string | false |
CheckboxGroup | List<int> | false |
RadioGroup | dynamic | true |
DateTimeField | DateTime | true |
Selector | List | false |
SwitchGroup | List<int> | false |
SwitchInline | bool | false |
NumberField | num | true |
Slider | double | false |
RangeSlider | RangeValues | false |
project status #
developing
develop plan #
- support insert field
- performance test
- support more fields