Isar delete function NoSuchMethodError: Class 'TransactionModel' has no instance method '[]'

36 Views Asked by At

I have a model called TransactionModel:

class TransactionModel {
  final Id id = Isar.autoIncrement;
  final DateTime dateTransaction;
  final String concept;
  final double ammountDouble;
}

I can call up lists of data and see them on the screen but when use function delete:

collectionData =  isarDB.transactionModels;

The id does not come directly from the database, but I first convert the data into a map to use it in the UI, then I pass the data into an int

await isarDB.writeTxn(() async {
  await collectionData.delete(id);
});

E/flutter (27274): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: NoSuchMethodError: Class 'TransactionModel' has no instance method '[]'. E/flutter (27274): Receiver: Instance of 'TransactionModel' E/flutter (27274): Tried calling: `

I want to know how to solve the problem and why it happens.

0

There are 0 best solutions below