【问题标题】:Undefined name 'ConflictAlgorithm'未定义名称“冲突算法”
【发布时间】:2021-06-18 05:26:57
【问题描述】:

执行插入查询时出错

final dbPath = await sql.getDatabasesPath();
    final db = await sql.openDatabase(path.join(dbPath, 'history.db'),
        onCreate: (db, version) {
      return db.execute(
          'CREATE TABLE history(id TEXT PRIMARY KEY, senderEmail TEXT, receiverEmail TEXT, amount REAL)');
    }, version: 1);

await db.insert(table, data, conflictAlgorithm: ConflictAlgorithm.replace);

当我通过 ConflictAlgorithm.replace 时发生错误,说

未定义名称“冲突算法”。尝试将名称更正为已定义的名称,或定义名称

另外,我正在关注:

【问题讨论】:

    标签: flutter sqflite


    【解决方案1】:

    您似乎正在导入带有前缀 (sql) 的 sqflite,而不是

    ConflictAlgorithm.replace
    

    你应该使用:

    sql.ConflictAlgorithm.replace
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-13
      • 2014-09-16
      • 1970-01-01
      • 2017-10-31
      • 2023-02-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多