Flutter query snapshot - map to list if conditional is met #3376
Unanswered
OGmetamonkey
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am mapping a Firestore query snapshot to a listview of listtiles. I only want to map values with }).toList(), that contain a certain search word "testSearch".
I wrote the following code, but it simply maps the whole list or doesn't map anything, based on the first conditional:
(if (testVal.contains(testSearch) || testSearch == null || testSearch == '') {).
I actually need to check the 'entry" value prior to the .toList() function based on my search word, but I can't figure it out.
There are a few other questions slightly related on stack out there, but they either don't handle streams, or they require me to bloat the code. It seems like there would be a more elegant solution. Here are the other related Q's:
https://stackoverflow.com/questions/50567295/listview-filter-search-in-flutter
https://stackoverflow.com/questions/61024941/flutter-change-list-based-on-variable-number
Beta Was this translation helpful? Give feedback.
All reactions