lo_form 0.0.1-dev.0 copy "lo_form: ^0.0.1-dev.0" to clipboard
lo_form: ^0.0.1-dev.0 copied to clipboard

outdated

Lightweight forms library for Flutter.

LoForm #

style: lint

๐Ÿงช LoForm is still experimental, missing features and bugs are to be expected.

LoForm is a low-code and lightweight Flutter form library, inspired by Formik โ€” the world's most popular form library for React, used in production at Airbnb, Stripe, NASA and more.

Features #

  1. No boilerplate: 90% less code compared to bloc + formz.
  2. Informational: provides a lot of useful states (touched, status, error) for each field in the form.
  3. Server-errors friendly: unlike flutter_form_builder which requires external errors to be managed by a separate state.
  4. Reusable and easy validation: uses the builder pattern for building validations.

Simple Usage #

This is a simple example, for a more complex one see the RegisterForm widget.

class SimpleForm extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    // [1] Wrap your form with [LoForm] widget.
    return LoForm(
      // [2] Implement what happens when the form is submitted.
      onSubmit: (values) async {
        print('Hi, ${values.get('name')}!');
        return true; // Successful submission
      },
      builder: (form) {
        return Column(
          children: [
            // [3] Use [LoTextField] instead of the normal [TextField].
            LoTextField(
              // [4] This name will be used to get the field's value.
              name: 'name',
              // [5] Provide a validation scheme using [LoValidation].
              validate: LoValidation().required().build(),
            ),
            const SizedBox(height: 32),
            ElevatedButton(
              // [6] Call the [submit] method depending on form [status].
              onPressed: form.status.isValid ? form.submit : null,
              child: const Text('Submit'),
            ),
          ],
        );
      },
    );
  }

}
30
likes
0
pub points
53%
popularity

Publisher

unverified uploader

Lightweight forms library for Flutter.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, provider

More

Packages that depend on lo_form