phongyewtong
phongyewtong

Reputation: 5319

How do i insert a var into sql statement on flutter sqflite?

How do i insert a var into sql statement on flutter sqflite? $Constants.dbColName doesnt work

  Future<int> save(Item item) async {
    final db = await database;

    return db.delete(
      Constants.dbTableName, 
      where: '$Constants.dbColName = ?',
      whereArgs: [item.name],  
    );
  }

Upvotes: 0

Views: 402

Answers (1)

Darish
Darish

Reputation: 11491

posting @pskink s comment as an answer for future reference.


Use parenthesis to wrap the variable.

${Constants.dbColName}

Upvotes: 2

Related Questions