sqlPlaceholders function

String sqlPlaceholders(
  1. int count, {
  2. String separator = ',',
})

Builds a comma-separated run of count bind placeholders for an IN (…) clause: sqlPlaceholders(3) ⇒ '?,?,?'.

count must be non-negative; 0 yields the empty string (the caller is responsible for not emitting an empty IN ()). The separator defaults to ',' — pass ', ' only when a human will read the SQL, since the two are equivalent to SQLite.

Implementation

String sqlPlaceholders(int count, {String separator = ','}) {
  if (count < 0) {
    throw ArgumentError.value(count, 'count', 'must be non-negative');
  }
  return List<String>.filled(count, '?').join(separator);
}