form_bloc icon indicating copy to clipboard operation
form_bloc copied to clipboard

What would you like to change about form_bloc - flutter_form_bloc?

Open GiancarloCode opened this issue 3 years ago • 8 comments

Hello, this week I will work on a new version of form_bloc that will allow creating complex fields, which include filters, searches, in a very simple way, I cannot give more details about it, since it currently uses private code that will be open source these days, but they will surely like it ;)

As I will change the core a bit, I would like you to tell me how you would like it to be form_bloc - flutter_form_bloc, and also what do you think it is missing, or what you would like to change.

For example:

  • Would you like another syntax / API? which?
  • Can't you do something? Tell me what and what API would you like to have to do it?
  • Something else

Any comment is helpful to improve, so thank you very much for your time.

GiancarloCode avatar Jun 24 '21 00:06 GiancarloCode

@GiancarloCode Please use cubit instead of bloc cubit updates values in sync way and it's easier to manage states see https://github.com/GiancarloCode/form_bloc/issues/228

sm2017 avatar Jun 26 '21 06:06 sm2017

@GiancarloCode a FormBloc.validate() is required to validate form without submitting FormBloc.submit() validate and submit form and there is no way to only trigger form validation

sm2017 avatar Jul 06 '21 05:07 sm2017

I would like to be able to override the default suggestions item builder. I have some suggestions where I need to provide more information to the user.

JulianSwales avatar Jul 21 '21 22:07 JulianSwales

@GiancarloCode please add Theme feature, such as TextFieldBlocTheme to let us change decoration of all children fields

sm2017 avatar Jul 26 '21 13:07 sm2017

SelectFieldBloc to accept items in async way(e.g from future). Also in some cases it's good to have a option to convert BooleanFieldBloc value to int in the json.

proxain avatar Aug 11 '21 07:08 proxain

I love to see material-like styles. variations Filled or Outlined.

anupdebnath avatar Aug 26 '21 20:08 anupdebnath

I'd like some documented examples of integrating other widgets.. There are a couple examples in the issues pages, but you have to go find them, and whilst I've managed to get it too work, it's an adventure each time.

JulianSwales avatar Aug 26 '21 23:08 JulianSwales

  1. Convert validation functions into objects, so you can build widgets based on validators: For example, a validator that contains the maximum and minimum length of the string that can be passed directly to the widget without duplicate code
final field = TextFieldBloc(
  validators: [StringLenghtValidator(minLength: 5, maxLength: 10)],
);

TextField(
  maxLength: fieldState.validators.firstWhere((validator) => validator is StringLenghtValidator)?.maxLength,
);
  1. Convert errors from strings to objects so you can build more detailed errors. For example we could have an error describing the maximum and minimum length of the string which will be passed to errorBuilder
class StringLenghtValidator extends Validator<String> {
  final int minLength;
  
  Object? validate(String value) {
    if (value.length < minLength {
      return StringLenghtError(minLength);
    }
    // ....
  }
}

class StringLenghtError {
  final int minLength;

  StringLenghtError(this.minLength);
}

final field = TextFieldBloc(
  validators: [StringLenghtValidator(minLength: 5, maxLength: 10)],
);

TextFieldBlocBuilder(
  errorBuilder: (context, error) {
    if (error is StringLenghtError) {
     return 'Write at least ${error.minLength} characters';
    }
  },
);

BreX900 avatar Aug 30 '21 08:08 BreX900