form_bloc
form_bloc copied to clipboard
What would you like to change about form_bloc - flutter_form_bloc?
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 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
@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
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.
@GiancarloCode please add Theme
feature, such as TextFieldBlocTheme
to let us change decoration of all children fields
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.
I love to see material-like styles. variations Filled or Outlined.
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.
- 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,
);
- 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';
}
},
);