Search code examples
flutterauto-incrementsqflite

At Flutter, how to insert into sqflite table but the table doesn't have an id with auto increment integer?


I see that sqflite database helper instance insert function returns Future<int>. I understand if my table uses INTEGER PRIMARY KEY AUTO_INCREMENT as id. But what if my id is STRING PRIMARY KEY NOT NULL? What will be returned from the function, as the function insists to return Future<int>? How can I make the return value becomes Future<String>? Or can I just ignore this return value?


Solution

  • Every SQLite table has an integer row id (https://www.sqlite.org/rowidtable.html) even if you use a text primary key. In this case you can ignore the return value.