execScalar method

Future execScalar(
  1. String pSql, [
  2. List? arguments
])

Run Select Command and return first col of first row

Implementation

Future<dynamic> execScalar(String pSql, [List<dynamic>? arguments]) async {
  final Database db = (await this.db)!;
  if (!pSql.contains(' LIMIT ')) {
    pSql += ' LIMIT 1';
  }
  final result = await db.rawQuery(pSql, arguments);

  if (result.isNotEmpty) {
    return result.first.values.first;
  } else {
    return null;
  }
}