I updated my code this way; I think it's better than the previous version.
List<Model> findAndOperate({
required double value,
required Operations operations,
required List<Model> mainList,
required List<Model> selectedList,
}) {
for (final item in mainList) {
if (selectedList.contains(item)) {
final itemIndex = mainList.indexOf(item);
final changeItem = switch (operations) {
Operations.PLUS => item.copyWith(price: item.price + value),
Operations.MULTIPLICATION => item.copyWith(price: item.price * value)
};
mainList[itemIndex] = changeItem;
}
}
return mainList;
}