Flutter Sqlite Exception,No such table, SQL 逻辑错误

Flutter Sqlite Exception,No such table, SQL logic Error

我正在使用 Flutter 创建自己的待办事项应用程序。当我编译并尝试在 sqlite 数据库中插入数据时,出现此错误 Flutter Sqlite Exception,No such table task, SQL logic Error.

注:我用的是moor_ffimoor ,并使用命令 flutter packages pub run build_runner build.

生成 database.g.dart 文件

来自沼泽 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.

因此,每次修改数据库后,您都需要重新安装应用程序或增加数据库中的架构版本。

  @override
  int get schemaVersion => 2;