All

I am trying to search from table but its not working satisfactory.

can any one help me to figure out where is my mistake.

Here is the Search Code: var namelist contains received data and var usersFiltered is duplicate list in which i am trying to implement search functionality

Column(
        children: [
          Card(
            child: new ListTile(
              leading: new Icon(Icons.search),
              title: new TextField(
                  controller: controller,
                  decoration: new InputDecoration(
                      hintText: 'Search', border: InputBorder.none),
                  onChanged: (value) {

                    if (value.isEmpty) {
                      setState(() {
usersFiltered!.clear();
usersFiltered=namelist;
});
                    }

                      else {

                        namelist?.forEach((nm) {
                          if (nm.name.toLowerCase().contains(value.toLowerCase()) ||
                              nm.year.toString().contains(value.toLowerCase()) || nm.color.toString().contains(value.toLowerCase())|| nm.pantone_value.toString().contains(value.toLowerCase())) {
                            result?.add(nm);
                          }
                        });
                        setState(() {
                         usersFiltered!.clear();
                        usersFiltered?.addAll(result!);    });
                      }

                    }),

              trailing: new IconButton(
                icon: new Icon(Icons.cancel),
                onPressed: () {
                  setState(() {
                    controller.clear();
                    _searchResult = '';
                    usersFiltered = namelist;
                  });
                },
              ),
            ),
          ),

        ],
      ),

Initial Data to Rows

 rows: usersFiltered!.map((nameone) {
                return DataRow(cells: [
                  DataCell(Text(nameone.id.toString(), textAlign: TextAlign.center),),
                  DataCell(Text(nameone.name.toString(), textAlign: TextAlign.center)),
                  DataCell(Text(nameone.year.toString())),
                  DataCell(Text(nameone.color.toString())),
                  DataCell(Text(nameone.pantone_value.toString())),

                ],);

              }).toList()),

Please Help to resolve it. Search not Working Smoothly and As per Need.