[ad_1]
I am creating chips with state notifier. And im itemizing them with Wrap Widget.
For an additional web page im attempting to transform this enter chips to filter chips as a result of there must be picks.
That is my chip mannequin
class ChipModel {
remaining String id;
remaining String title;
remaining String title;
remaining bool isSelected;
const ChipModel(
{required this.id,
required this.title,
required this.title,
required this.isSelected});
ChipModel copy({String? id, String? title, String? title, bool? isSelected}) =>
ChipModel(
id: id ?? this.id,
title: title ?? this.title,
title: title ?? this.title,
isSelected: isSelected ?? this.isSelected);
@override
bool operator ==(Object different) =>
an identical(this, different) ||
different is ChipModel &&
runtimeType == different.runtimeType &&
title == different.title &&
title == different.title &&
isSelected == different.isSelected;
@override
int get hashCode => title.hashCode ^ title.hashCode ^ isSelected.hashCode;
}
That is my different web page to indicate consumer chips that she/he add
Shopper(builder: (BuildContext context, WidgetRef ref, _) {
Listing<ChipModel> skillChips = ref.learn(skillProvider);
var watch = ref.watch(controller);
return Column(
youngsters: [
Align(
alignment: Alignment.bottomLeft,
child: Wrap(
alignment: WrapAlignment.start,
spacing: 10,
children: skillChips
.map((filterChip) => FilterChip(
label: Text(filterChip.name),
labelStyle: TextStyle(
fontWeight: FontWeight.bold,
),
backgroundColor: AppColors.warning,
onSelected: (isSelected) => setState(() {
skillChips = skillChips.map((otherChip) {
return filterChip == otherChip
? otherChip.copy(
isSelected: isSelected)
: otherChip;
}).toList();
}),
selected: filterChip.isSelected,
checkmarkColor: AppColors.primary,
selectedColor: AppColors.danger,
))
.toList(),
),
),
const SizedBox(
height: 15,
),
],
);
})
However filterChip.isSelected by no means turns true . Even when it turns true when state rebuild it comes false once more.
[ad_2]
