wahyu
wahyu

Reputation: 2415

How to implement search in PaginatedDataTable Flutter Web

Hi I have a PaginatedDataTable and right now I would like to make it searchable so when I type some keyword it would show the data according to the keyword that users type... I have been searching some articles about it, but I didn't find yet... anyone knows some tutorials or articles or examples about it?

Upvotes: 2

Views: 1569

Answers (1)

Şerefcan Oğuz
Şerefcan Oğuz

Reputation: 159

dataList: _searchController.text == ""
      ? widget.dataList
      : searchList,
actions: [
      AnimatedSearchBar(
          width: 300,
          textController: _searchController,
          onSuffixTap: () {
            setState(() {
              _searchController.text = "";
            });
          }),)]

they are PaginatedDataTable properties

  @override
  void initState() {
    super.initState();
     if (searchableItemList.length != 0 && widget.dataList.length != 0) {
      _searchController.addListener(() {
        setState(() {
          searchList = dataList
        .where((element) => element
                .name
                .toLowerCase()
                .contains(controller.text.toLowerCase()))
        .toList();;
        });
      });
    }}

Upvotes: -1

Related Questions