Flutter - Sqflite Query Values Match Any Values In List

• 1 min read •

As you may know, in order to query values that match any values in a predefined list, you can use the IN check.

For example:

SELECT *
FROM categories
WHERE id IN (1, 2, 3, 4)

It’s easy for raw SQL but how to achieve that using Sqflite?

final ids = [1, 2, 3, 4]
db.query(
    'categories',
    where: "id IN (${ids.map((_) => '?').join(', ')})",
    whereArgs: ids,
);

The main point is to generate enough ? placeholders in your where statement and you’re good to go!

Happy coding! 💻

Iced Tea Labs

A technical blog managed by a geek who loves climbing

GitHub Twitter RSS

© 2026 Trinh Le. All rights reserved.