Flutter Sqlite Exception,No such table, SQL logic Error

Issue

I’m creating on my own a to-do app using Flutter. When I compile and try to insert a data in sqlite database, I got this error Flutter Sqlite Exception,No such table task, SQL logic Error.

Note: I use moor_ffi, moor
,and generate the database.g.dart file using command flutter packages pub run build_runner build.

Solution

From moor documentation:

Why am I getting no such table errors?

If you add another table after your app has already been installed,
you need to write a migration that covers creating that table. If
you’re in the process of developing your app and want to use un- and
reinstall your app instead of writing migrations, that’s fine too.
Please note that your apps data might be backed up on Android, so
manually deleting your app’s data instead of a reinstall is necessary
on some devices.

So everytime you have modified your database, you need to re-install your app or increase the schema version in your database.

  @override
  int get schemaVersion => 2;

Answered By – John Joe

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

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