separating folder

This commit is contained in:
hannathkadher
2025-01-05 15:59:11 +04:00
parent b59e7e4836
commit ae09cbda1e
9 changed files with 289 additions and 203 deletions

View File

@ -1,30 +0,0 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/selected_product_model.dart';
class AddDeviceTypeModelBloc extends Cubit<List<SelectedProduct>> {
AddDeviceTypeModelBloc(List<SelectedProduct> initialProducts)
: super(initialProducts);
void updateProductCount(String productId, int count) {
final existingProduct = state.firstWhere(
(p) => p.productId == productId,
orElse: () => SelectedProduct(productId: productId, count: 0),
);
if (count > 0) {
if (!state.contains(existingProduct)) {
emit([...state, SelectedProduct(productId: productId, count: count)]);
} else {
final updatedList = state.map((p) {
if (p.productId == productId) {
return SelectedProduct(productId: p.productId, count: count);
}
return p;
}).toList();
emit(updatedList);
}
} else {
emit(state.where((p) => p.productId != productId).toList());
}
}
}