insert method

  1. @override
Future<void> insert(
  1. String table,
  2. Map<String, dynamic> data
)
override

Inserts a row. Throws StateError if a row with the same id exists. Caller supplies all sync metadata fields; the adapter does not populate them.

Implementation

@override
Future<void> insert(String table, Map<String, dynamic> data) async {
  final rows =
      _tables.putIfAbsent(table, () => <String, Map<String, dynamic>>{});
  final id = data[SyncColumns.id] as String;
  if (rows.containsKey(id)) {
    throw StateError('Row $id already exists in $table');
  }
  rows[id] = Map<String, dynamic>.from(data);
}