Coder Social home page Coder Social logo

Comments (30)

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024 1

Try replacing below code

    /// List of all products
    List<ProductModel> list = widget.product;

With

 /// List of all products
    List<ProductModel> list = List.from(widget.product);

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024 1

Try replacing below code

 onApplyButtonClick: (list) {
    widget.product.forEach((element) {
      if (list!.any((model) => model.status == element.status)) {
        selectedUserList.add(element);
      }
    });
    // setState(() {  });
    setState(() {
      selectedUserList = List.from(list!);
    });
    // Navigator.pop(context);
  },

with

 onApplyButtonClick: (list) {
      if(selectedUserList == null){
         selectedUserList = [];
        }
          widget.product.forEach((element) {
             if (list.any((model) => model.status == element.status)) {
               selectedUserList.add(element);
             }
            });
          setState(() {  });
           // Navigator.pop(context);
        },

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024 1

We need to handle a case where onApplyButtonClick returns empty or null list.

Try replacing below code

 onApplyButtonClick: (list) {
    widget.product.forEach((element) {
      if (list!.any((model) => model.status == element.status)) {
        selectedUserList.add(element);
      }
    });
    // setState(() {  });
    setState(() {
      selectedUserList = List.from(list!);
    });
    // Navigator.pop(context);
  },

with

 onApplyButtonClick: (list) {
  if(!(list != null && list.isNotEmpty)){
    
      setState(() {
          selectedUserList = []; /// Now we have assigned null value to `selectedUserList` then you have to add null check value in ui where `selectedUserList` is used.
       });
      return;
   }
     if (selectedUserList == null) {
      selectedUserList = [];
    } else {
      widget.product.forEach((element) {
        if (list!.any((model) => model.status == element.status)) {
          selectedUserList.add(element);
        }
      });
    }
    setState(() {
      selectedUserList = List.from(selectedUserList);
    });
  },

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024 1

@AathifMahir Now you understand Why I was saying that you can remove duplicate values after passing to the sdk.

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024 1

@TheAlphamerc I think it would be great that if this merging duplicate items in choicechip would be built into filter_list module as boolean value to enable or disable merging duplicate choicechip items

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

@TheAlphamerc Hi, I'm waiting for your take on this issue, will be waiting for your reply

Thanks

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024

Hi @AathifMahir, If you don't want to display duplicates item in choice chip then you can remove those duplicate items from list before providing the list to the FilterListDialog.

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

Hi @AathifMahir, If you don't want to display duplicates item in choice chip then you can remove those duplicate items from list before providing the list to the FilterListDialog.

I have tried that since the choice chip is built based on the data that's available in the list based on index, I can't seem to remove that, i need to find a way to merge data from choice chip after the data is built and merge those indexes

Do you have any suggestions for that?

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024

Can you share the sample list data that you are using ?

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

@TheAlphamerc you can check this video for better understanding on the scenario that I'm currently facing

The data is coming from firestore

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024

I didn't understand what you trying to say through video. Help me understanding the issue, I'll try to find a way to resolve this.

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

I didn't understand what you trying to say through video. Help me understanding the issue, I'll try to find a way to resolve this.

Accessing the data using provider with a modal for Productsdata, the datas were pulled from firestore based on the attributes,

By the way all the single data has the status eg: halal lv1, halal lv2, haram lv1, etc..

The status is the things that used for data filtering that built inside the chicechip, since status is available in every single object, the all single status available in the data gets built inside the choicechip based on index on data,

Now, i need to merge those duplicates status into single item in choicechip

Eg: there's multiple status called Halal Lv1 inside the choice chip, i need to make that single item, likewise all other different status

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024

What you are passing to the FilterListDialog ?
I mean List<String> or List<Object>

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

What you are passing to the FilterListDialog ?

I mean List<String> or List<Object>

I'm passing List' into FilterListDialog

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024

What type of List you are passing ?

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

What type of List you are passing ?

List with ProductModel as data

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

Give me couple of minutes, I'll share my full code

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024

That would be helpful.

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024

@AathifMahir do share the code of _openFilterDialog method instead of screenshot.

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

@TheAlphamerc Here you go

late List<ProductModel> selectedUserList = [];

  void _openFilterDialog() async {
    await FilterListDialog.display<ProductModel>(
       context,
       listData: widget.product,
       selectedListData: selectedUserList,
       height: 480,
       // headlineText: "Select Users",
       searchFieldHintText: "Search Here",
       choiceChipLabel: (item) {
          return item!.status;
        },
       hideCloseIcon: true,
       hideheader: true,
       hideHeaderText: true,
       hideSearchField: true,
       backgroundColor: Theme.of(context).colorScheme.background,
       applyButonTextBackgroundColor: Theme.of(context).colorScheme.primary,
       selectedTextBackgroundColor: Theme.of(context).colorScheme.primary,
       borderRadius: MySize.size5!,
       controlButtonTextStyle: Theme.of(context).textTheme.subtitle2,
       applyButtonTextStyle: Theme.of(context).textTheme.subtitle2,
       unselectedTextbackGroundColor: Theme.of(context).disabledColor,
       controlContainerDecoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(MySize.size3!))),
        // buttonRadius: MySize.size5!,
       validateSelectedItem: (list, val) {
          return list!.contains(val);
       },
       onApplyButtonClick: (list) {
          setState(() {
             selectedUserList = List.from(list!);
           });
           // Navigator.pop(context);
        },

       /// uncomment below code to create custom choice chip
       choiceChipBuilder: (context, item, isSelected) {
          return Container(
             padding: EdgeInsets.symmetric(
                 horizontal: MySize.size10, vertical: MySize.size10),
             margin: EdgeInsets.symmetric(
                 horizontal: MySize.size10, vertical: MySize.size10),
             decoration: BoxDecoration(
               borderRadius: BorderRadius.all(Radius.circular(MySize.size3!)),
                  color: isSelected!
                    ? Theme.of(context).colorScheme.primary
                    : Theme.of(context).disabledColor,
               ),
              child: Text(
                item!.status,
                 style:
                  AppTheme.getTextStyle(Theme.of(context).textTheme.subtitle2),
            ));
       },
    );
  }

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024

@AathifMahir Before passing the all data list to the FilterListDialog remove duplicate elements. Have a look on below code.

late List<ProductModel> selectedUserList = [];

void _openFilterDialog() async {
  
   /// List of all products
    List<ProductModel> list = widget.product;
  
    var uniqueList = list.map((e) => e.status).toSet();
   
   /// Remove duplicate products having same uniqueTempList
    list.retainWhere((x) => uniqueList.remove(x.status));

    /// List of all selected products
    List<ProductModel> tempSelectedList = selectedUserList;
   
     if(selectedUserList != null and selectedUserList.isNotEmpty){
       var uniqueTempList = tempSelectedList.map((e) => e.status).toSet();
   
        /// Remove duplicate selected products having same 
        tempSelectedList.retainWhere((x) => uniqueTempList.remove(x.status));
      }
   


    await FilterListDialog.display<ProductModel>(
       context,
       listData:list,
       selectedListData: tempSelectedList,
       height: 480,
    
       searchFieldHintText: "Search Here",
       choiceChipLabel: (item) {
          return item!.status;
        },
       validateSelectedItem: (list, val) {
          return list!.contains(val);
       },
       onApplyButtonClick: (list) {
          widget.product.forEach((element) {
             if (list.any((model) => model.status == element.status)) {
               selectedUserList.add(element);
             }
            });
          setState(() {  });
           // Navigator.pop(context);
        },

       /// uncomment below code to create custom choice chip
       choiceChipBuilder: (context, item, isSelected) {
          return Container(
             padding: EdgeInsets.symmetric(
                 horizontal: MySize.size10, vertical: MySize.size10),
             margin: EdgeInsets.symmetric(
                 horizontal: MySize.size10, vertical: MySize.size10),
             decoration: BoxDecoration(
               borderRadius: BorderRadius.all(Radius.circular(MySize.size3!)),
                  color: isSelected!
                    ? Theme.of(context).colorScheme.primary
                    : Theme.of(context).disabledColor,
               ),
              child: Text(
                item!.status,
                 style:
                  AppTheme.getTextStyle(Theme.of(context).textTheme.subtitle2),
            ));
       },
    );
  }

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

@AathifMahir Before passing the all data list to the FilterListDialog remove duplicate elements. Have a look on below code.

late List<ProductModel> selectedUserList = [];

void _openFilterDialog() async {
  
   /// List of all products
    List<ProductModel> list = widget.product;
  
    var uniqueList = list.map((e) => e.status).toSet();
   
   /// Remove duplicate products having same uniqueTempList
    list.retainWhere((x) => uniqueList.remove(x.status));

    /// List of all selected products
    List<ProductModel> tempSelectedList = selectedUserList;
   
     if(selectedUserList != null and selectedUserList.isNotEmpty){
       var uniqueTempList = tempSelectedList.map((e) => e.status).toSet();
   
        /// Remove duplicate selected products having same 
        tempSelectedList.retainWhere((x) => uniqueTempList.remove(x.status));
      }
   


    await FilterListDialog.display<ProductModel>(
       context,
       listData:list,
       selectedListData: tempSelectedList,
       height: 480,
    
       searchFieldHintText: "Search Here",
       choiceChipLabel: (item) {
          return item!.status;
        },
       validateSelectedItem: (list, val) {
          return list!.contains(val);
       },
       onApplyButtonClick: (list) {
          widget.product.forEach((element) {
             if (list.any((model) => model.status == element.status)) {
               selectedUserList.add(element);
             }
            });
          setState(() {  });
           // Navigator.pop(context);
        },

       /// uncomment below code to create custom choice chip
       choiceChipBuilder: (context, item, isSelected) {
          return Container(
             padding: EdgeInsets.symmetric(
                 horizontal: MySize.size10, vertical: MySize.size10),
             margin: EdgeInsets.symmetric(
                 horizontal: MySize.size10, vertical: MySize.size10),
             decoration: BoxDecoration(
               borderRadius: BorderRadius.all(Radius.circular(MySize.size3!)),
                  color: isSelected!
                    ? Theme.of(context).colorScheme.primary
                    : Theme.of(context).disabledColor,
               ),
              child: Text(
                item!.status,
                 style:
                  AppTheme.getTextStyle(Theme.of(context).textTheme.subtitle2),
            ));
       },
    );
  }

@TheAlphamerc Sorry, You must've misunderstood. I only need to remove duplicate status not the products. I need to have all the products show as before whenever filter a status like Halal Lv1, that means all the products has that status should be shown on listview.

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024

@AathifMahir Before passing the all data list to the FilterListDialog remove duplicate elements. Have a look on below code.

late List<ProductModel> selectedUserList = [];

void _openFilterDialog() async {
  
   /// List of all products
    List<ProductModel> list = widget.product;
  
    var uniqueList = list.map((e) => e.status).toSet();
   
   /// Remove duplicate products having same uniqueTempList
    list.retainWhere((x) => uniqueList.remove(x.status));

    /// List of all selected products
    List<ProductModel> tempSelectedList = selectedUserList;
   
     if(selectedUserList != null and selectedUserList.isNotEmpty){
       var uniqueTempList = tempSelectedList.map((e) => e.status).toSet();
   
        /// Remove duplicate selected products having same 
        tempSelectedList.retainWhere((x) => uniqueTempList.remove(x.status));
      }
   


    await FilterListDialog.display<ProductModel>(
       context,
       listData:list,
       selectedListData: tempSelectedList,
       height: 480,
    
       searchFieldHintText: "Search Here",
       choiceChipLabel: (item) {
          return item!.status;
        },
       validateSelectedItem: (list, val) {
          return list!.contains(val);
       },
       onApplyButtonClick: (list) {
          widget.product.forEach((element) {
             if (list.any((model) => model.status == element.status)) {
               selectedUserList.add(element);
             }
            });
          setState(() {  });
           // Navigator.pop(context);
        },

       /// uncomment below code to create custom choice chip
       choiceChipBuilder: (context, item, isSelected) {
          return Container(
             padding: EdgeInsets.symmetric(
                 horizontal: MySize.size10, vertical: MySize.size10),
             margin: EdgeInsets.symmetric(
                 horizontal: MySize.size10, vertical: MySize.size10),
             decoration: BoxDecoration(
               borderRadius: BorderRadius.all(Radius.circular(MySize.size3!)),
                  color: isSelected!
                    ? Theme.of(context).colorScheme.primary
                    : Theme.of(context).disabledColor,
               ),
              child: Text(
                item!.status,
                 style:
                  AppTheme.getTextStyle(Theme.of(context).textTheme.subtitle2),
            ));
       },
    );
  }

This will display only unique status in filter dialog box when you make some selection then it will display all those products having selected status. It won't remove the products from the list that you are displaying.

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

@TheAlphamerc But, it removes the product as well

from flutter_plugin_filter_list.

TheAlphamerc avatar TheAlphamerc commented on July 4, 2024

Have you tried the code ?

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

Yes, i have tried that code, Give me sec i'll share the code

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

@TheAlphamerc

late List selectedUserList = [];

void _openFilterDialog() async {
List list = widget.product;

var uniqueList = list.map((e) => e.status).toSet();

/// Remove duplicate products having same uniqueTempList
list.retainWhere((x) => uniqueList.remove(x.status));

/// List of all selected products
List<ProductModel> tempSelectedList = selectedUserList;

if (selectedUserList != null && selectedUserList.isNotEmpty) {
  var uniqueTempList = tempSelectedList.map((e) => e.status).toSet();

  /// Remove duplicate selected products having same
  tempSelectedList.retainWhere((x) => uniqueTempList.remove(x.status));
}

await FilterListDialog.display<ProductModel>(
  context,
  listData: list,
  selectedListData: tempSelectedList,
  height: 480,
  // headlineText: "Select Users",
  searchFieldHintText: "Search Here",
  choiceChipLabel: (item) {
    return item!.status;
  },
  hideCloseIcon: true,
  hideheader: true,
  hideHeaderText: true,
  hideSearchField: true,
  backgroundColor: Theme.of(context).colorScheme.background,
  applyButonTextBackgroundColor: Theme.of(context).colorScheme.primary,
  selectedTextBackgroundColor: Theme.of(context).colorScheme.primary,
  borderRadius: MySize.size5!,
  controlButtonTextStyle: Theme.of(context).textTheme.subtitle2,
  applyButtonTextStyle: Theme.of(context).textTheme.subtitle2,
  unselectedTextbackGroundColor: Theme.of(context).disabledColor,
  controlContainerDecoration: BoxDecoration(
      borderRadius: BorderRadius.all(Radius.circular(MySize.size3!))),
  // buttonRadius: MySize.size5!,
  validateSelectedItem: (list, val) {
    return list!.contains(val);
  },

  onItemSearch: (list, text) {
    if (list != null) {
      if (list.any((element) =>
          element.status!.toLowerCase().contains(text.toLowerCase()))) {
        /// return list which contains matches
        return list
            .where((element) =>
                element.status!.toLowerCase().contains(text.toLowerCase()))
            .toList();
      }
    }

    return [];
  },

  onApplyButtonClick: (list) {
    widget.product.forEach((element) {
      if (list!.any((model) => model.status == element.status)) {
        selectedUserList.add(element);
      }
    });
    // setState(() {  });
    setState(() {
      selectedUserList = List.from(list!);
    });
    // Navigator.pop(context);
  },

  /// uncomment below code to create custom choice chip
  choiceChipBuilder: (context, item, isSelected) {
    // return Container(
    //   padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
    //   margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
    //   decoration: BoxDecoration(
    //       border: Border.all(
    //     color: isSelected! ? Colors.blue[300]! : Colors.grey[300]!,
    //   )),
    //   child: Text(
    //     item.status,
    //     style: TextStyle(
    //         color: isSelected ? Colors.blue[300] : Colors.grey[300]),
    //   ),
    // );
    return Container(
        padding: EdgeInsets.symmetric(
            horizontal: MySize.size10, vertical: MySize.size10),
        margin: EdgeInsets.symmetric(
            horizontal: MySize.size10, vertical: MySize.size10),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(MySize.size3!)),
          color: isSelected!
              ? Theme.of(context).colorScheme.primary
              : Theme.of(context).disabledColor,
        ),
        child: Text(
          item!.status,
          style:
              AppTheme.getTextStyle(Theme.of(context).textTheme.subtitle2),
        ));
  },
);

}

Only 2 products were showing since all the duplicates in the choice chips were removed, there should be around 7 to products totally

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

Try replacing below code

    /// List of all products
    List<ProductModel> list = widget.product;

With

 /// List of all products
    List<ProductModel> list = List.from(widget.product);

Still the same, still showing only 2 products

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

@TheAlphamerc Everything seems to working fine except top 2 products,

here's the code

late List selectedUserList = List.from(widget.product);

void _openFilterDialog() async {
List list = List.from(widget.product);

var uniqueList = list.map((e) => e.status).toSet();

/// Remove duplicate products having same uniqueTempList
list.retainWhere((x) => uniqueList.remove(x.status));

/// List of all selected products
List<ProductModel> tempSelectedList = selectedUserList;

if (selectedUserList != null && selectedUserList.isNotEmpty) {
  var uniqueTempList = tempSelectedList.map((e) => e.status).toSet();

  /// Remove duplicate selected products having same
  tempSelectedList.retainWhere((x) => uniqueTempList.remove(x.status));
}

await FilterListDialog.display<ProductModel>(
  context,
  listData: list,
  selectedListData: tempSelectedList,
  height: 480,
  // headlineText: "Select Users",
  searchFieldHintText: "Search Here",
  choiceChipLabel: (item) {
    return item!.status;
  },
  hideCloseIcon: true,
  hideheader: true,
  hideHeaderText: true,
  hideSearchField: true,
  backgroundColor: Theme.of(context).colorScheme.background,
  applyButonTextBackgroundColor: Theme.of(context).colorScheme.primary,
  selectedTextBackgroundColor: Theme.of(context).colorScheme.primary,
  borderRadius: MySize.size5!,
  controlButtonTextStyle: Theme.of(context).textTheme.subtitle2,
  applyButtonTextStyle: Theme.of(context).textTheme.subtitle2,
  unselectedTextbackGroundColor: Theme.of(context).disabledColor,
  controlContainerDecoration: BoxDecoration(
      borderRadius: BorderRadius.all(Radius.circular(MySize.size3!))),
  // buttonRadius: MySize.size5!,
  validateSelectedItem: (list, val) {
    return list!.contains(val);
  },

  onItemSearch: (list, text) {
    if (list != null) {
      if (list.any((element) =>
          element.status!.toLowerCase().contains(text.toLowerCase()))) {
        /// return list which contains matches
        return list
            .where((element) =>
                element.status!.toLowerCase().contains(text.toLowerCase()))
            .toList();
      }
    }

    return [];
  },

  onApplyButtonClick: (list) {
    if (selectedUserList == null) {
      selectedUserList = [];
    } else {
      widget.product.forEach((element) {
        if (list!.any((model) => model.status == element.status)) {
          selectedUserList.add(element);
        }
      });
    }
    setState(() {
      selectedUserList = List.from(selectedUserList);
    });
  },

  /// uncomment below code to create custom choice chip
  choiceChipBuilder: (context, item, isSelected) {
    // return Container(
    //   padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
    //   margin: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
    //   decoration: BoxDecoration(
    //       border: Border.all(
    //     color: isSelected! ? Colors.blue[300]! : Colors.grey[300]!,
    //   )),
    //   child: Text(
    //     item.status,
    //     style: TextStyle(
    //         color: isSelected ? Colors.blue[300] : Colors.grey[300]),
    //   ),
    // );
    return Container(
        padding: EdgeInsets.symmetric(
            horizontal: MySize.size10, vertical: MySize.size10),
        margin: EdgeInsets.symmetric(
            horizontal: MySize.size10, vertical: MySize.size10),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(MySize.size3!)),
          color: isSelected!
              ? Theme.of(context).colorScheme.primary
              : Theme.of(context).disabledColor,
        ),
        child: Text(
          item!.status,
          style:
              AppTheme.getTextStyle(Theme.of(context).textTheme.subtitle2),
        ));
  },
);

}

from flutter_plugin_filter_list.

AathifMahir avatar AathifMahir commented on July 4, 2024

@TheAlphamerc Fixed the issue, Thanks a lot for help

here's complete code:

late List<ProductModel> selectedUserList = List.from(widget.product);

  void _openFilterDialog() async {
    List<ProductModel> list = List.from(widget.product);

    debugPrint("Data List: ${list.toString()}");

    var uniqueList = list.map((e) => e.status).toSet();

    /// Remove duplicate products having same uniqueTempList
    list.retainWhere((x) => uniqueList.remove(x.status));

    /// List of all selected products
    List<ProductModel> tempSelectedList = selectedUserList;

    if (selectedUserList != null && selectedUserList.isNotEmpty) {
      var uniqueTempList = tempSelectedList.map((e) => e.status).toSet();

      /// Remove duplicate selected products having same
      tempSelectedList.retainWhere((x) => uniqueTempList.remove(x.status));
    }

    await FilterListDialog.display<ProductModel>(
      context,
      listData: list,
      selectedListData: tempSelectedList,
      height: 480,
      // headlineText: "Select Users",
      searchFieldHintText: "Search Here",
      choiceChipLabel: (item) {
        return item!.status;
      },
      hideCloseIcon: true,
      hideheader: true,
      hideHeaderText: true,
      hideSearchField: true,
      backgroundColor: Theme.of(context).colorScheme.background,
      applyButonTextBackgroundColor: Theme.of(context).colorScheme.primary,
      selectedTextBackgroundColor: Theme.of(context).colorScheme.primary,
      borderRadius: MySize.size5!,
      controlButtonTextStyle: Theme.of(context).textTheme.subtitle2,
      applyButtonTextStyle: Theme.of(context).textTheme.subtitle2,
      unselectedTextbackGroundColor: Theme.of(context).disabledColor,
      controlContainerDecoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(MySize.size3!))),
      // buttonRadius: MySize.size5!,
      validateSelectedItem: (list, val) {
        return list!.contains(val);
      },

      onItemSearch: (list, text) {
        if (list != null) {
          if (list.any((element) =>
              element.status!.toLowerCase().contains(text.toLowerCase()))) {
            /// return list which contains matches
            return list
                .where((element) =>
                    element.status!.toLowerCase().contains(text.toLowerCase()))
                .toList();
          }
        }

        return [];
      },

      onApplyButtonClick: (list) {
        if (!(list != null && list.isNotEmpty)) {
          setState(() {
            selectedUserList = [];
            list = [];

            /// Now we have assigned null value to `selectedUserList` then you have to add null check value in ui where `selectedUserList` is used.
          });
          return;
        }
        if (selectedUserList == null || list == null) {
          setState(() {
            selectedUserList = [];
            list = [];
          });
        } else {
         widget.product.forEach((element) {
            if (list!.any((model) => model.status == element.status)) {
              debugPrint("Elements: ${element.status}");
              selectedUserList.add(element);
              if (list!.contains(element) != true) {
                list!.add(element);
              }
            }
          });
        }
        setState(() {
          selectedUserList = List.from(list!);
        });
      
      },

      /// uncomment below code to create custom choice chip
      choiceChipBuilder: (context, item, isSelected) {
      return Container(
            padding: EdgeInsets.symmetric(
                horizontal: MySize.size10, vertical: MySize.size10),
            margin: EdgeInsets.symmetric(
                horizontal: MySize.size10, vertical: MySize.size10),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.all(Radius.circular(MySize.size3!)),
              color: isSelected!
                  ? Theme.of(context).colorScheme.primary
                  : Theme.of(context).disabledColor,
            ),
            child: Text(
              item!.status,
              style:
                  AppTheme.getTextStyle(Theme.of(context).textTheme.subtitle2),
            ));
      },
    );
  }

from flutter_plugin_filter_list.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.