flutterobjectbox

ObjectBox dynamic queries


e.g. the end user makes selections from two of five possible filters, the last three filters being left as ‘all’.

Rather than me creating queries for every possible combination of the 5 filters (25 different queries in total), what is the most efficient syntax for handling this?

Should I use .and to chain the queries together, and then can I specify ‘all’ for any which are not required?


Solution

  • A query builder can be used to build the query according to the selected filters. That is adding query criteria only using inside if conditions checking for the the filters.