form_bloc 0.5.1 copy "form_bloc: ^0.5.1" to clipboard
form_bloc: ^0.5.1 copied to clipboard

outdated

Easy Form State Management using BLoC pattern. Separate the Form State and Business Logic from the User Interface. Async Validation, Progress, Failures, Successes, and more.

example/main.dart

import 'package:form_bloc/form_bloc.dart';

class SimpleFormBloc extends FormBloc<String, String> {
  final dateFieldBloc = InputFieldBloc<TextFieldBloc>();

  final textField = TextFieldBloc();

  final booleanField = BooleanFieldBloc();

  final selectField = SelectFieldBloc<String>(
    items: ['Option 1', 'Option 2', 'Option 3'],
  );

  final multiSelectField = MultiSelectFieldBloc<String>(
    items: ['Option 1', 'Option 2', 'Option 3', 'Option 4'],
  );

  @override
  List<FieldBloc> get fieldBlocs => [
        dateFieldBloc,
        textField,
        booleanField,
        selectField,
        multiSelectField,
      ];

  @override
  Stream<FormBlocState<String, String>> onSubmitting() async* {
    // Awesome logic...

    // Print a valid value of each field bloc:
    print(dateFieldBloc.value);
    print(textField.value);
    print(booleanField.value);
    print(selectField.value);
    print(multiSelectField.value);

    yield currentState.toSuccess();
  }
}
156
likes
0
pub points
84%
popularity

Publisher

unverified uploader

Easy Form State Management using BLoC pattern. Separate the Form State and Business Logic from the User Interface. Async Validation, Progress, Failures, Successes, and more.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

bloc, equatable, meta, mockito, pedantic, quiver, rxdart

More

Packages that depend on form_bloc