query method Null safety

Future<List<Map<String, Object?>>> query(
  1. String table,
  2. {bool? distinct,
  3. List<String>? columns,
  4. String? where,
  5. List<Object?>? whereArgs,
  6. String? groupBy,
  7. String? having,
  8. String? orderBy,
  9. int? limit,
  10. int? offset}
)

This is a helper to query a table and return the items found. All optional clauses and filters are formatted as SQL queries excluding the clauses' names.

table contains the table names to compile the query against.

distinct when set to true ensures each row is unique.

The columns list specify which columns to return. Passing null will return all columns, which is discouraged.

where filters which rows to return. Passing null will return all rows for the given URL. '?'s are replaced with the items in the whereArgs field.

groupBy declares how to group rows. Passing null will cause the rows to not be grouped.

having declares which row groups to include in the cursor, if row grouping is being used. Passing null will cause all row groups to be included, and is required when row grouping is not being used.

orderBy declares how to order the rows, Passing null will use the default sort order, which may be unordered.

limit limits the number of rows returned by the query.

offset specifies the starting index.

 List<Map> maps = await db.query(tableTodo,
     columns: ['columnId', 'columnDone', 'columnTitle'],
     where: 'columnId = ?',
     whereArgs: [id]);

Implementation

Future<List<Map<String, Object?>>> query(String table,
    {bool? distinct,
    List<String>? columns,
    String? where,
    List<Object?>? whereArgs,
    String? groupBy,
    String? having,
    String? orderBy,
    int? limit,
    int? offset});