all method

Future<List?> all({
  1. int? paginate,
})

Implementation

Future<List?> all({int? paginate}) async {
  Database db = await database;

  if (paginate != null) {
    limit(paginate);
  }
  if (_query.isEmpty) {
    _query += "SELECT * FROM $table";
  }

  List<Map<String, Object?>> result = await db.rawQuery(_query, _bindings);

  if (result.isEmpty) return null;

  List list = [];

  for (Map data in result) {
    Map newMap = {};
    data.forEach((k, v) {
      if (v.runtimeType.toString() == "DateTime") {
        newMap[k] = (v as DateTime).toIso8601String();
      } else if (v.runtimeType.toString() == "bool") {
        newMap[k] = v as bool ? 1 : 0;
      } else {
        newMap[k] = v;
      }
    });

    _result.add(newMap);
    list.add(fromMap(newMap));
  }
  return list;
}