query method

Future<SQLiteCursor> query ({bool distinct: false, @required String table, List<String> columns, String where, List<String> whereArgs, String groupBy, String having, String orderBy, Object limit })

Query the given table, returning a Cursor over the result set.

See: https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase#query(boolean,%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)


Future<SQLiteCursor> query({
  final bool distinct = false,
  @required final String table,
  final List<String> columns,
  final String where,
  final List<String> whereArgs,
  final String groupBy,
  final String having,
  final String orderBy,
  final Object limit,
}) async {
  final Map<String, dynamic> request = <String, dynamic>{
    'id': id,
    'distinct': distinct,
    'table': table,
    'columns': columns,
    'selection': where, // note the name mapping
    'selectionArgs': whereArgs, // note the name mapping
    'groupBy': groupBy,
    'having': having,
    'orderBy': orderBy,
    'limit': limit?.toString(),
  final List<dynamic> result = await _channel.invokeMethod('query', request);
  assert(result.length == 2);
  final List<String> cursorColumns =
      (result[0] as List<dynamic>).cast<String>();
  final List<List<dynamic>> cursorRows =
      (result[1] as List<dynamic>).cast<List<dynamic>>();
  return SQLiteCursor.from(columns: cursorColumns, rows: cursorRows);