form_bloc 0.11.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 95

form_bloc #

PackagePub
form_blocpub package
flutter_form_blocpub package

Easy Form State Management using BLoC pattern. Separate the Form State and Business Logic from the User Interface.

🔥👉 Documentation and Tutorials 👈🔥 #

  • [x] Synchronous Field Validation
  • [x] Asynchronous Field Validation
  • [x] Easy Loading and Initializing
  • [x] Wizard / Stepper Forms
  • [x] Submission Progress
  • [x] Success / Failure Response
  • [x] Serializable Form
  • [x] Submission Errors to Fields
  • [x] Dynamic Fields
  • [x] Conditional Fields
  • [x] List Fields
  • [x] Group Fields
  • [x] CRUD Support
  • [x] Beautiful Built-In Widgets

To create beautiful forms in Flutter using form_bloc check out flutter_form_bloc.

Examples #

Maintainers #

0.11.0 #

Breaking changes #

  • Add support for forms with steps.
    • Use AddFieldBloc({int step, List<FieldBloc> fieldBlocs}).
  • All SingleFieldBlocs now have ExtraData type.
  • Changes FieldBlocList to ListFieldBloc.
  • Add GroupFieldBloc as base class for create typed groups of field blocs.
  • Add toJson method to FormBlocState.
  • Remove FormBlocState.getFieldBlocFromPath.
  • Add valueOf method to FormBlocState.
  • Add fieldBlocOf method to FormBlocState.
  • Remove onReload of FormBloc, now when you call FormBloc.reload, onLoading will be called.
  • Add onValueChanges StreamSubscription to SingleFieldBloc.
  • Add FormBlocUpdatingFields state.
  • Add isRequired parameter to FieldBloc, and the error is FieldBlocValidatorsError.required, so the follow validators are removed:
    • FieldBlocValidators.requiredInputFieldBloc
    • FieldBlocValidators.requiredBooleanFieldBloc
    • FieldBlocValidators.requiredTextFieldBloc
    • FieldBlocValidators.requiredSelectFieldBloc
    • FieldBlocValidators.requiredMultiSelectFieldBloc
  • Add FormBlocUpdatingFields state.
  • Add progress property to FormBlocLoading and FormBlocDeleting.
  • Change Stream<State> onSubmitting() to void onSubmitting().
  • Change Stream<State> onLoading() to void onLoading().
  • Change Stream<State> onDeleting() to void onDeleting().
  • Add methods for emit new states:
    • emitSuccess
    • emitFailure
    • emitSubmitting
    • emitLoading
    • emitLoadFailed
    • emitLoaded
    • emitSubmissionCancelled
    • emitDeleteFailed
    • emitDeleteSuccessful
    • emitUpdatingFields

0.10.4 #

  • Fixed minor bug.

0.10.3 #

  • Fixed hasFailureResponse property of FormBlocLoadFailed, FormBlocFailure and FormBlocDeleteFailed.

0.10.2 #

  • Changes FieldBloc.addError(String error) to FieldBloc.addError(String error, {bool isPermanent = false}).
  • Documentation Updates.

0.10.1 #

  • clear method of FieldBloc now call updateInitialValue instead of updateValue.
  • Fixed clear method of FormBloc.
  • Documentation Updates.

0.10.0 #

Breaking changes #

  • Removed fieldBlocs getter of FormBloc. now you must use addFieldBloc method.
  • Renamed onDelete method of FormBloc to onDeleting.
  • Added canSubmitAgain parameter to toSuccess method of FormBlocState.
  • Now FieldBloc can be dynamically added to a FormBloc with addFieldBloc.
  • Now FieldBloc can be dynamically removed from a FormBloc with removeFieldBloc.
  • Added fieldBlocs property to FormBlocState.
  • FieldBloc is now implemented by 3 classes:
    • SingleFieldBloc which is the Interface of:
      • InputFieldBloc.
      • TextFieldBloc.
      • BooleanFieldBloc.
      • SelectFieldBloc.
      • MultiSelectFieldBloc.
    • GroupFieldBloc.
    • FieldBlocList.
  • Documentation Updates.

0.8.0 #

  • Added isEditing property to FormBlocState (#9).
  • Added delete event to FormBloc (#9).
  • Added toDeleteFailed and toDeleteSuccessful methods to FormBlocState (#9).
  • If the initialValue of TextFieldBloc is null is will be an empty String ''.
  • If the initialValue of BooleanFieldBloc is null it will be false.
  • If the initialValue of MultiSelectFieldBloc is null it will be an empty list [].

0.7.0 #

  • Updated to bloc: ^3.0.0

0.6.0 #

  • Updated to bloc: ^1.0.0
    • bloc.state.listen -> bloc.listen
    • bloc.currentState -> bloc.state
    • dispatch -> add
    • dispose -> close
  • Documentation Updates.
  • Validators -> FieldBlocValidators
  • ValidatorsError -> FieldBlocValidatorsErrors
  • Removed isRequired property from FieldBloc and FieldBlocState.

0.5.2 #

  • Documentation Updates.
  • Fixed a bug in isValid property of fieldBlocState.
  • Prevented to update FieldBloc.value if is the same value and is validated.
  • Improved requiredTextFieldBloc validator.

0.5.1 #

  • Fixed a bug in MultiSelectFieldBloc.

0.5.0 #

  • Dependency and Documentation Updates.
  • Added isValidating property to FieldBlocState.
  • Added asyncValidators property to FieldBloc.
  • Added asyncValidatorDebounceTime property to FieldBloc.
  • Added addAsyncValidators method to FieldBloc.
  • Added updateAsyncValidators method to FieldBloc.
  • Added addError method to FieldBloc.
  • Added subscribeToFieldBlocs method to FieldBloc.

0.4.1 #

  • Documentation Updates.

0.4.0 #

  • Documentation Updates.
  • Added Tests.
  • Added autoValidate property to FormBloc.
  • Added InputFieldBloc<Value>.
  • Removed FileFieldBloc, now you can use InputFieldBloc<File>.
  • Added MultiSelectFieldBloc<Value>.
  • Added error property to FieldBlocState.
  • Added canShowError property to FieldBlocState.
  • Added canShowProgress property to FieldBlocState.
  • Added suggestions property to FieldBlocState.
  • Added isRequired property to FieldBlocState.
  • Changes TextFieldBloc<Error> to TextFieldBloc.
  • Added valueToInt property to TextFieldBlocState.
  • Added valueToDouble property to TextFieldBlocState.
  • Added FormBlocDelegate.

0.3.1 #

  • Added isCanceling property to FormBlocSubmitting.

0.3.0 #

  • Dependency and Documentation Updates.
  • Added submissionProgress property to FormBlocState.
  • Added canSubmit property to FormBlocState.
  • Added FormBlocSubmissionFailed state to FormBloc.
  • Added FormBlocSubmissionCancelled state to FormBloc.
  • Added cancelSubmission event to FormBloc.
  • Added updateState event to FormBloc.
  • Added onCancelSubmission method to FormBloc.
  • Added FileFieldBloc.

0.2.0 #

  • Documentation Updates

0.1.0 #

  • Initial Version of the library.

example/main.dart

import 'package:form_bloc/form_bloc.dart';

class LoginFormBloc extends FormBloc<String, String> {
  final email = TextFieldBloc(
    isRequired: true,
    validators: [
      FieldBlocValidators.email,
    ],
  );

  final password = TextFieldBloc(
    isRequired: true,
  );

  LoginFormBloc() {
    addFieldBlocs(
      fieldBlocs: [
        email,
        password,
      ],
    );
  }

  @override
  void onSubmitting() {
    print(email.value);
    print(password.value);
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  form_bloc: ^0.11.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:form_bloc/form_bloc.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
90
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
95
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
bloc ^3.0.0 3.0.0
bloc_test ^4.0.0 4.0.0
collection ^1.14.11 1.14.12
equatable ^1.1.0 1.1.1
meta ^1.1.6 1.1.8
mockito ^4.1.1 4.1.1
pedantic ^1.8.0+1 1.9.0
quiver ^2.0.5 2.1.3
rxdart ^0.23.0 0.23.1 0.24.0-dev.1
uuid ^2.0.4 2.0.4
Transitive dependencies
_fe_analyzer_shared 1.0.3
analyzer 0.39.4
args 1.6.0
async 2.4.1
boolean_selector 2.0.0
charcode 1.1.3
convert 2.1.1
coverage 0.13.9
crypto 2.1.4
csslib 0.16.1
glob 1.2.0
html 0.14.0+3
http 0.12.0+4
http_multi_server 2.2.0
http_parser 3.1.4
io 0.3.3
js 0.6.1+1
logging 0.11.4
matcher 0.12.6
mime 0.9.6+3
multi_server_socket 1.0.2
node_interop 1.0.3
node_io 1.0.1+2
node_preamble 1.4.8
package_config 1.9.3
path 1.6.4
pool 1.4.0
pub_semver 1.4.4
shelf 0.7.5
shelf_packages_handler 2.0.0
shelf_static 0.2.8
shelf_web_socket 0.2.3
source_map_stack_trace 2.0.0
source_maps 0.10.9
source_span 1.7.0
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
test_api 0.2.15
test_core 0.3.3
typed_data 1.1.6
vm_service 4.0.0
watcher 0.9.7+14
web_socket_channel 1.1.0
webkit_inspection_protocol 0.5.0+1
yaml 2.2.0
Dev dependencies
test ^1.6.0 1.14.2