Questions tagged [sqflite]

Use this tag for questions about the plugin for flutter named sqflite - which enables storage, retrieval, and manipulation of SQLite databases via flutter code.

sqflite is an plugin for . Supports both and .

Package documentation: sqflite

902 questions
7
votes
1 answer

how to update page state after Navigator.pop() from an alert box

I have 2 pages in my Flutter app - ShoppingListsPage and ItemsListPage. I have a FloatingActionButton in ShoppingListsPage clicking which will take the user to ItemsListPage where he can add items from a ListView to a shopping list and then save the…
Rakesh K
  • 8,237
  • 18
  • 51
  • 64
6
votes
2 answers

Loading assets in Flutter for desktop (Windows)

I am trying to load SQLite DB in Flutter for Windows (it's working on Android), but I receive an exception, my code is : // Copy from asset ByteData data = await rootBundle.load(join("assets", "mydb.sqlite")); List bytes =…
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
6
votes
15 answers

How can I fix "Future isn't a type" error in flutter?

I'm trying to store app data of my flutter application in the database, but the complier keeps showing "Future isn't a type" for async func and underlines in red. I've tried removing .analysis-driver as well, but that doesn't help. How can I fix it…
Ayush Nanglia
  • 89
  • 1
  • 3
  • 10
6
votes
2 answers

How to get last entry from sqlite in flutter?

I have seen many answers in SO but all are related to android. I want to get the last ID entered in the table.This is my user table: await db.execute("CREATE TABLE User(" "userId INTEGER PRIMARY KEY," "first_name TEXT," …
Mrunal Joshi
  • 367
  • 1
  • 4
  • 11
6
votes
2 answers

Updating field in SQLite (Flutter)

Let's use this code snippet as an example. The data model is very simple: class Dog { final int id; final String name; final int age; Dog({this.id, this.name, this.age}); } To update the information, I'm using this function: Future
Bassam
  • 497
  • 4
  • 12
6
votes
2 answers

How to store JSON data into database table in flutter using SQFLite or Moor Library

How do I insert the list of String in database in flutter app, I tried saving it in string datatype by encoding the json array into the string, but then the skills array requires explicit decoding every time, like below whenever I need the object…
Sidhant Rajora
  • 307
  • 4
  • 16
5
votes
1 answer

Access SQLite DB in Flutter

I am creating a DB in my native Android code using SQLite. Now I want to access the same DB in Flutter, below is my code: class DatabaseHelper { static final _dbName="abc.db"; static final _dbVersion=1; …
Benson OO
  • 477
  • 5
  • 22
5
votes
2 answers

Listen to Stream and write only once to DB in Flutter

I'm developing a QR code reader app and I use an external QR reader package (https://pub.dev/packages/qr_code_scanner). It listens to a Stream and returns QR data. But when I write the data to sqlite database it writes the same data several times…
Dulanka
  • 139
  • 9
5
votes
4 answers

How to update version database SQFLite flutter?

I need to create new tables and delete others in my local database, however changing only the database version, it does not work it is not creating the new tables that I need. In the same way I already tried the onUpgrade but it did not…
5
votes
2 answers

How can I use Provider for async data? (Flutter)

Background I am building super simple TODO list app for practicing Flutter. If you input a string and click "add", then the text is shown in the list on the upper part. Question When and how should I call model.getTasks() (= update data…
dmjy
  • 1,183
  • 3
  • 10
  • 26
5
votes
1 answer

How do I use sqflite and only query 1 row of data on flutter

How do I use sqflite and only query 1 row of data on flutter. Future queryOneDaily (int id, String date) async { final db = await database; return await db.query( Constants.dbTable, where: "${Constants.dbColId} = ?…
phongyewtong
  • 5,085
  • 13
  • 56
  • 81
5
votes
4 answers

how to query sqflite multiple whereArgs on flutter?

How do I query multiple whereArgs? I always return 1 row. it should return 3 rows. final res = await db.query( Constants.dbTable, where: "name = ?", whereArgs: ['read', "uio", 'go'], );
phongyewtong
  • 5,085
  • 13
  • 56
  • 81
5
votes
1 answer

How to check if a database exists before creating a table?

How do you check whether a database exists before creating a table for the database in Flutter using sqflite? E.g., if I'm to create the database doggie_database.db, how do I prematurely check its existence within table creation? final…
evergreen
  • 681
  • 10
  • 22
5
votes
1 answer

any alternative SQL for flutter rather than sqflite

I was wonder if there any alternative way to store offline data in dependencies database rather than using sqflite!! if any one knows any SQL or even nosql libraries for flutter that's is not complicated like sqflite please mention it!
Mo Ok
  • 544
  • 6
  • 20
5
votes
2 answers

How to add new table to sqlite?

I need to add a new column name id INTEGER AUTOINCREMENT and a new table for the current database for my existing table. How to use 'onUpgrade'? Is it need to change the version number? initDb() async { io.Directory documentsDirectory = await…
user11065582
1 2
3
59 60