Reputation: 599
List<String> topics = [
'Photography',
'News',
'Facts',
'How-to',
'Technology',
'Science',
'Space',
];
I have a list of about 70-80 words. I want to search this list and make it searchable even if a spelling mistake is made. The list is also case-sensitive. No UI needed.
How can I do it in Flutter/Dart?
For example if I type 'tec', the Techonology
topic should be the result. The topics are case sensitive, but the query should handle this too.
Upvotes: 0
Views: 392
Reputation: 5742
Try below one
List<String> topics = [
'Photography',
'News',
'Facts',
'How-to',
'Technology',
'Science',
'Space',
];
var text='ence';
var _searchResult = topics.where(
(topics) => (topics.contains(text) ||
topics.toLowerCase().contains(text))
);
print(_searchResult.toString());
Upvotes: 2