what I want to do is that my search history can update it, I can´t delete a previous search with click on the delete icon but I want to use the set state but it gives me an error and the reason may be that I am not using a StatefulWiget because I am using a Search delegate. I would appreciate the help. Code::
class SearchDelegateMenuPrincipal extends SearchDelegate<SearchDelegateModel>{
@override
final String searchFieldLabel;
List<SearchDelegateModel> historialMenuPrincipal=[];
SearchDelegateModel busquedaa;
final menuprincipalservices = new MenuPrincipalServices();
SearchDelegateMenuPrincipal(this.searchFieldLabel,this.historialMenuPrincipal);
@override
List<Widget> buildActions(BuildContext context) {
//code
}
@override
Widget buildLeading(BuildContext context) {
return Container(
//code
),
);
}
@override
Widget buildResults(BuildContext context) {
//code
}
@override
Widget buildSuggestions(BuildContext context) {
return HistorialBusquedaSuggestions(this.historialMenuPrincipal );
}
Widget HistorialBusquedaResults(List <SearchDelegateModel> BusquedaHistorial ){
//code
}
Widget HistorialBusquedaSuggestions(List <SearchDelegateModel> historialMenuPrincipal ){
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white
),
child: ListView.builder(
itemCount: historialMenuPrincipal.length,
itemBuilder: (context,i){
contentPadding: EdgeInsets.symmetric(vertical: 12,horizontal: 16);
leading:CircleAvatar(
radius: 32,
backgroundImage: NetworkImage(
"https://9.bp.blogspot.com/-3ZzNZsjQk/WR94I4II/AAAAAAAAAJw/_inTVynS60V75IZ-461-paWArTSwCEw/s1600/ANA.jpg"),
);
return ListTile(
title: Text(historialMenuPrincipal[i].email?? "no hay data"),
trailing: IconButton(
icon: Icon(Icons.cancel,color: Colors.black,),
onPressed: () {
setState((context) {
busqueda.remove(busqueda[]); // i want to use this
});
},
),
);
}
),
);
}