insertReturning method Null safety

Future<D> insertReturning(
  1. Insertable<D> entity,
  2. {InsertMode? mode,
  3. UpsertClause<T, D>? onConflict}

Inserts a row into the table, and returns a generated instance.

Note: This uses the RETURNING syntax added in sqlite3 version 3.35, which is not available on most operating systems by default. When using this method, make sure that you have a recent sqlite3 version available. This is the case with sqlite3_flutter_libs.


Future<D> insertReturning(Insertable<D> entity,
    {InsertMode? mode, UpsertClause<T, D>? onConflict}) async {
  final ctx = createContext(entity, mode ?? InsertMode.insert,
      onConflict: onConflict, returning: true);

  return database.doWhenOpened((e) async {
    final result = await e.runSelect(ctx.sql, ctx.boundVariables);
        .notifyUpdates({TableUpdate.onTable(table, kind: UpdateKind.insert)});