I’ve developed a search screen using bloc patter to filter local list data. Here my problem is every-time I search filter the list the search box too get reloaded due to event change. Any solutions to fix such issue.
@override
Widget build(BuildContext context) {
return BlocProvider<Bloc>(
create: (context) => Bloc(),
child: Scaffold(
appBar: AppBar(leading:leading),
body: BlocBuilder(
bloc: _bloc,
builder: (context, BlocState state) {
return Column(
children: [
TextFormField(controller:controller,
onChanged: (filterKey) {
_bloc.add(Search(state.listData,filterKey));
},
),
ListView.builder(....),
],
);
},
),
),
);
}
2
Answers
You can possibly try wrapping
TextFormField
insideStatefulBuilder
like: