int 不是一种类型

use*_*163 6 sql dart flutter

在将版本传递给 on create 方法和我想从数据库中获取的 id 的 integer(int) 时,我收到一条错误消息,指出“int 不是类型”错误图像

class NewsDbProvider {
  Database db;

  int() async {

    Directory documentsDirectory =await getApplicationDocumentsDirectory();
    final path = join(documentsDirectory.path, "items.db");

    db = await openDatabase(
        path,
        version: 1,
        onCreate: (Database newDb,int version){
          newDb.execute("""
            CREATE TABLE Items
            (

            )
            """);
        }
    );
  }

  fetchItem(int id) async{
    db.query(
      "Items",
      columns: null,
      where: 'id = ?',
      whereArgs: {id},
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

Sve*_*ven 5

您将方法命名为NewsDbProvideras int,这就是关键字不再被识别的原因。尝试重命名它。