addAll method Null safety

Future<List<K>> addAll(
  1. DatabaseClient databaseClient,
  2. List<V> values
)

Add multiple records, returns the list of generated keys.

Implementation

Future<List<K>> addAll(DatabaseClient databaseClient, List<V> values) async {
  final client = getClient(databaseClient);
  var sanitizedValues = values
      .map((value) => client.sembastDatabase.sanitizeInputValue<V>(value));
  var keys = <K>[];
  await client.inTransaction((txn) async {
    var store = client.getSembastStore(this);
    for (var value in sanitizedValues) {
      keys.add((await store.txnAdd<K, V>(txn, value))!);
    }
  });
  return keys;
}