I have used FilterChip and using it many screens...but to avoid duplicate and lengthy codes i want to create customFilterChip widget with only three properties
onSelect method label String isSelected bool
but i dont know how to deal with onSelect method while creating final method...
class CustomFilterChipWidget extends StatelessWidget {
final bool isSelected;
final String lable;
//how declare function onSelect;
const CustomFilterChipWidget({Key? key,required this.isSelected,required this.lable,required this.onSelect}) : super(key: key);
@override
Widget build(BuildContext context) {
return FilterChip(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
showCheckmark: false,
selectedColor: Colors.white,
backgroundColor: Colors.white,
shape: StadiumBorder(
side: BorderSide(
width: isSelected ? 2 : 0,
color: isSelected
? Colors.blue
: Colors.grey),
),
selected: isSelected,
label: Text(
lable,),
onSelected: onSelect);
}
}
as in filter chip
it requires value in argument
onSelected: (value) {
}