autoform 0.0.3 copy "autoform: ^0.0.3" to clipboard
autoform: ^0.0.3 copied to clipboard

outdated

A simple package to help you build forms. A form builder with code controlled validation.

autoform #

A simple package to help you build forms.

Getting Started #

Straight forward form builder.

Simple implementation #



class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {

  var form = AutoForm(
    values: {'name': 'Edwards'},
    properties: [
      AutoProperty(
        field: 'name',
        title: 'Name',
        validator: AutoValidators.isEmail,
        type: AutoPropertyType.text,
      ),
      AutoProperty(
          field: 'personality',
          title: 'Personality Type',
          validator: AutoValidators.isEmail,
          type: AutoPropertyType.multiselect,
          options: ['Simple', 'Complex', 'Other']),
    ],
  ).create();

  @override
  void initState() {
    super.initState();
    var s = AutoFormSettings();
    s.fieldMargin = EdgeInsets.symmetric(vertical: 20);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: Column(
          children: [
            form.widget,
            ElevatedButton(
              onPressed: () {
                var isValid = form.form.validate();
                if (isValid) {
                  print("Form validated");
                } else {
                  print("Errors");
                }
              },
              child: Text("Validate"),
            ),
          ],
        ),
      ),
    );
  }
}


1
likes
0
pub points
14%
popularity

Publisher

unverified uploader

A simple package to help you build forms. A form builder with code controlled validation.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on autoform