Skip to content

v0.5.0-dev.1

Pre-release
Pre-release
Compare
Choose a tag to compare
@felangel felangel released this 03 May 22:28
· 41 commits to main since this release
3587e3d

0.5.0-dev.1

  • docs: use nullable validator in README

  • feat: add example Flutter app

  • BREAKING: decouple purity, validity, and submission status

    Changes

    1. FormzStatus renamed to FormzSubmissionStatus:
    /// Enum representing the submission status of a form.
    enum FormzSubmissionStatus {
    /// The form is in the process of being submitted.
    inProgress,
    
    /// The form has been submitted successfully.
    success,
    
    /// The form submission failed.
    failure,
    
    /// The form submission has been canceled.
    canceled
    }
    1. FormzInput class no longer exposes a status (FormzInputStatus). Instead there are isValid and isNotValid getters:
    class NameInput extends FormzInput<String, NameInputError> {
    const NameInput.pure() : super.pure('');
    const NameInput.dirty({String value = ''}) : super.dirty(value);
    
    @override
    NameInputError? validator(String value) {
        return value.isNotEmpty == true ? null : NameInputError.empty;
    }
    }
    
    void main() {
    const name = NameInput.pure();
    print(name.isValid); // false
    print(name.isNotValid); // true
    
    const joe = NameInput.dirty(value: 'joe');
    print(joe.isValid); // true
    print(joe.isNotValid); // false
    }
    1. FormzInput has a displayError getter which returns an error to display if the input is not valid and has been modified by the user (closes #44)
    void main() {
    const name = NameInput.pure();
    print(name.displayError); // null
    
    const invalid = NameInput.dirty(value: '');
    print(name.displayError); // NameInputError.empty
    }
    1. Renamed pure to isPure for consistency