updateAlternativeInputs method
UPDATE ALTERNATIVE VALUE
Implementation
List<PairwiseAlternativeInput> updateAlternativeInputs(
List<PairwiseAlternativeInput> currentAlternativeInputs, {
required String? criteriaId,
required String? alternativeId,
required int scale,
required bool isLeftMoreImportant,
}) {
return currentAlternativeInputs.map((e) {
if (e.criteria.id == criteriaId) {
final updatedAlternatives = e.alternative.map((alt) {
if (alt.id == alternativeId) {
return alt.copyWith(
preferenceValue: scale,
isLeftMoreImportant: isLeftMoreImportant,
);
}
return alt;
}).toList();
return e.copyWith(alternative: updatedAlternatives);
}
return e;
}).toList();
}