UI not re-rendering when select field's values is updating since 0.30.0
EzraBerendsen opened this issue · 4 comments
I just updated flutter_form_bloc to 0.30.0 and then to 0.30.1 and it seems like the functionality has changed on when to render if a select field is updated.
I have a text field that is dependant on what value is selected from the SelectFieldBloc, but since 0.30.0 it no longer re-renders the UI, thus leaving me with the problem that the UI is incorrect.
First I thought it was a mistake on my part, but it seems like reverting to 0.29.1 does the trick, so not quite sure what has been changed to the rendering logic.
I would gladly solve this in a PR, but my dart nor my bloc skills are good enough. 😬
can you show me an example with this issue?
can you show me an example with this issue?
import 'package:flutter/material.dart';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
class FormBlocExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: BlocProvider(
create: (context) => Bloc(),
child: BlocBuilder<Bloc, FormBlocState>(
builder: (context, state) {
final formBloc = BlocProvider.of<Bloc>(context);
return Column(
children: [
DropdownFieldBlocBuilder<String>(
selectFieldBloc: formBloc.selectField,
decoration: InputDecoration(
labelText: 'DropdownFieldBlocBuilder222',
prefixIcon: Icon(Icons.sentiment_satisfied),
),
itemBuilder: (context, value) => FieldItem(
child: Text(value),
),
),
TextFieldBlocBuilder(
textFieldBloc: formBloc.textField,
decoration: InputDecoration(
labelText: 'TextFieldBlocBuilder',
prefixIcon: Icon(Icons.text_fields),
),
),
// This updates on <0.30.0, but doesn't get updated on version >0.30.0
formBloc.selectField.value == null
? Text("value is null?")
: Text(formBloc.selectField.value!),
],
);
},
),
),
);
}
}
class Bloc extends FormBloc {
Bloc() {
addFieldBlocs(fieldBlocs: [selectField, textField]);
}
final selectField = SelectFieldBloc(items: ['option 1', 'option 2']);
final textField = TextFieldBloc();
@override
void onSubmitting() {}
}
it's related to this issue #283 to avoid is just this, rendering the widgets listen to the FormBloc every time its FieldBloc changes.
by do the following
BlocBuilder(
bloc: formBloc.selectField,
builder: (context, state) {
return formBloc.selectField.value == null
? Text("value is null?")
: Text(formBloc.selectField.value!);
})
Ah! Interesting that this only showed up when updating to 0.30.0. I guess the API was maybe changed a bit? Thanks for the quick response! 🚀