How to debug moor: getting no such table error


I’m inserting data to my database and got the following error…

flutter: Moor: Sent INSERT INTO add_cash (name, amount, date, frequency, is_deleted) VALUES (?, ?, ?, ?, ?) with args [income, 100000, 1573102800, once, 0]

Does the question marks mean that the data wasn’t inserted into the database

Here is the button that sends data to database

  onPressed: () {
  child: Text('ADD CASH'),
void createAddCash() async {
  final database = Provider.of<AppDatabase>(context);
  final task = AddCashData(
      name: oneController.text,
      amount: int.parse(twoController.text),
      date: selectedDate,
      frequency: selectedItem,
      isDeleted: false);

Here is my database

class AddCash extends Table {
  IntColumn get id => integer().autoIncrement()();
  TextColumn get name => text()();
  IntColumn get amount => integer()();
  DateTimeColumn get date => dateTime()();
  TextColumn get frequency => text()();
  BoolColumn get isDeleted => boolean()();

@UseMoor(tables: [AddCash])
class AppDatabase extends _$AppDatabase {
      // Specify the location of the database file
      : super(
            path: 'db.sqlite',
            // Good for debugging - prints SQL in the console
            logStatements: true,
  int get schemaVersion => 1;

  Future insertAddCash(AddCashData addCashData) =>


Does the question marks mean that the data wasn’t inserted into the

No, it is not an error message. The question mark indicate the parameter that will be stored to the databse. I would suggest you add try-catch between your code, so you can check what is the error.

  try {
    final task = AddCashData(...);
   } catch (e) {
    print(e.toStirng()); // this line will be printed if there is any errors 

Answered By – John Joe

Answer Checked By – Mary Flores (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *