smart_form 0.0.2

  • Readme
  • Changelog
  • Installing
  • 65

smart_form #

A modified variant package of Form widget in flutter as SmartForm, with freedom of using auto-validation feature only when the form field state is changed at least once, opposite to the usual scenario wherein the auto validation starts as soon as the Form is initialised, and even if nothing is entered in the form yet.

This is pretty unwanted behavior for most of the product UX designs, wherein you would only want to validate when the user tries to do at least some change in the form field.

This form can be used to wrap any type of widget and use all the default features of the form on them. The package also modifies the TextFormField and DropDownButtonFormField for flexibility with auto-validation.

The package also consists of the required auto validation tests in the test folder.

Looking forward to add more features to the smart_form if required. Suggestions will be appreciated.

Related Issues/PRs #

A couple of developers including me have already raised some issues/PRs for the same, to the official Flutter git repository, as below:
#56132
#36154
#48876

PS: The code of the package uses most of the default flutter form widget code, with some changes, just for auto-validate to trigger only when the state of the FormField changes at least once. The flutter community is working on the related issues for the same which may take sometime to merge, to stable or beta channel. Till then you can make use of this package.

Getting Started #

If you want to use smart_form directly as a package, just click https://pub.dev/packages/smart_form#-installing-tab-

How to use SmartForm ? #

Same as you use your very own Form widget.

SmartForm buildForm(BuildContext context) {
    return SmartForm(
      key: formKey,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          // here this Form Field will start to auto validate only when the text field value is entered or changed at least once
          SmartTextFormField(
                  autovalidate: true,
                  initialValue: 'John Doe',
                  decoration: InputDecoration(
                    labelText: 'Enter Name',
                  ),
                  onSaved: (value) => your_save_method,             
                  validator: (value) => your_validation_method
                ),
          // Custom Form Field 
          SmartFormField(
                  autovalidate: true,
                  builder: (state) {
                    // This Search Text Field can be wrapping your default TextField internally
                    return MyCustomSearchTextField(
                      controller: my_text_edit_controller,
                      label: label,
                      errorText: state.errorText,
                    );
                  },
                  onSaved: (value) => your_save_method,
                  validator: (value) =>
                      your_validation_method,
                )
        ],
      ),
    );
  }

[0.0.1] - 2020-06-05 #

  • Add SmartForm and SmartFormField, along with SmartTextFormField and DropDownButtonFormField use uses SmartFromField,
  • with autovalidate only when state of the form is changed, at least once.

[0.0.2] - 2020-06-05 #

  • Update Readme with Related issues/PRs
  • Add few example code

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  smart_form: ^0.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:smart_form/smart_form.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
42
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • smart_form that is a package requiring null.

Health suggestions

Format lib/smart_form.dart.

Run flutter format to format lib/smart_form.dart.

Format lib/src/smart_drop_down_button_form_field.dart.

Run flutter format to format lib/src/smart_drop_down_button_form_field.dart.

Format lib/src/smart_form.dart.

Run flutter format to format lib/src/smart_form.dart.

Format lib/src/smart_text_form_field.dart.

Run flutter format to format lib/src/smart_text_form_field.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and smart_form.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

The description is too long. (-10 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test