Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(selectedProductFilters.isNotEmpty){
- List<CategoryProductData> filteredProducts = [];
- for (var selectedFilter in selectedProductFilters) {
- reagents.where((v) => v.ordering == 2).toList().forEach((allproduct) {
- allproduct.linkedProducts?.forEach((element) {
- if(element.title == selectedFilter){
- filteredProducts.add(allproduct);
- }
- });
- });
- if(selectedBrandFilters.isNotEmpty){
- List<CategoryProductData> brandFilteredData = [];
- for (var brand in selectedBrandFilters) {
- if(selectedParameterFilters.isNotEmpty) {
- filteredProducts.where((v) => v.ordering == 2).toList().forEach((element) {
- if (element.brand == brand &&
- (selectedParameterFilters.contains(element.tags))) {
- brandFilteredData.add(element);
- }
- });
- }
- else{
- filteredProducts.where((v) => v.ordering == 2).toList().forEach((element) {
- if (element.brand == brand) {
- brandFilteredData.add(element);
- }
- });
- }
- }
- filteredData.value = brandFilteredData;
- }
- else if(selectedParameterFilters.isNotEmpty){
- filteredProducts.where((v) => v.ordering == 2).toList().forEach((element) {
- if (selectedParameterFilters.contains(element.tags)) {
- filteredData.add(element);
- }
- });
- } else{
- filteredData.value = filteredProducts;
- }
- }
- }
- //no product filters selected
- else if(selectedBrandFilters.isNotEmpty){
- for (var brand in selectedBrandFilters) {
- if(selectedParameterFilters.isNotEmpty) {
- reagents.where((v) => v.ordering == 2).toList().forEach((element) {
- if (element.brand == brand &&
- (selectedParameterFilters.contains(element.tags))) {
- filteredData.add(element);
- }
- });
- }
- else{
- reagents.where((v) => v.ordering == 2).toList().forEach((element) {
- if (element.brand == brand) {
- filteredData.add(element);
- }
- });
- }
- }
- }
- //only parameter filter
- else if(selectedParameterFilters.isNotEmpty){
- reagents.where((v) => v.ordering == 2).toList().forEach((element) {
- if (selectedParameterFilters.contains(element.tags)) {
- filteredData.add(element);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement