Questions tagged [flutter-moor]

Moor is an easy to use, reactive persistence library for Flutter apps. It allows to define tables in Dart or SQL and provides a fluent query API, auto-updating streams and more.

Filter by
Sorted by
Tagged with
0 votes
0 answers
9 views

Flutter Drift package | Can you define queries in a separate file?

...or better yet, define them in various places like each entity's Model or Repository. My goal is to keep my database.dart file from becoming miles long because of ~6 CRUD functions per domain model, ...
0 votes
0 answers
186 views

Drift/Moor and Flutter app - database streams with arguments

I have a quiz app with sqlite base. I'm using Drift (former Moor). drift_db.dart (in a nutshell): class QuestionsBase extends Table { IntColumn get questionnumber => integer()(); TextColumn get ...
  • 46
2 votes
1 answer
127 views

Drift/Moor/Flutter StateError (Bad state: No element) when selecting single row with getSingle()

When retrieving data from a Drift database using the .getSingle() method, if there is no row matching the search criterion, a StateError (Bad state: No element) error is thrown. Is this expected ...
  • 33
-3 votes
1 answer
278 views

Flutter Drift - parameters prohibited in CHECK constraints

I'm trying to use the drift library (renamed from moor) ,but it's unable to create tables because of this error: SqliteException(1): parameters prohibited in CHECK constraints, SQL logic error (code 1)...
  • 2,338
0 votes
0 answers
108 views

How to map entity IDs to actual entities?

I'm building a mobile app in Flutter and am trying to figure out how to go about the following scenario: the REST API I am using returns unmapped data from the database i.e. { "id": 103152, &...
  • 11
0 votes
1 answer
380 views

Flutter: How to unit testing moor/drift?

I already implementation of Drift for local storage, and want make it testable function. But I get stack and idk how to fix it the unit test. HomeDao @DriftAccessor(tables: [RepositoriesTable]) class ...
1 vote
0 answers
261 views

Unique keys set not working on Drift Flutter

I have this table with a set of unique keys {id, order}. The problem is that when I create a new part in a different order, it automatically replaces the entire part. If I had the part with id 1 ...
  • 21
0 votes
0 answers
78 views

How to link two tables?

I have two tables: a table with groups and a table with students. There are two pages: on one, a group is created, and on the second, a student. They are created and written to the database. I need ...
  • 853
2 votes
0 answers
425 views

One-to-many relationships in drift(moor)

I have two tables: students and groups. I need to implement a one-to-many relationship of these tables so that when I create a student I have a list of groups from the database and I can add the ...
  • 853
1 vote
1 answer
77 views

How to return a list from a database?

In my code, which is presented below, I convert my group into a database model and add it to the database. Then I return the group object. and I need to return a list of groups that are added to the ...
  • 853
0 votes
1 answer
1k views

Drift stream not updating on insert, update and delete

I'm having problem when trying to display data on the UI where it should rebuild the widget prior to changes on menus table. I'm using GetX for the state management and Drift, a.k.a Moor as the ...
  • 1,849
1 vote
0 answers
29 views

E/flutter ( 8246): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value

I have this app i am almost done with but i keep getting an error i cant find in the code. Any flutter developer want to take a look at the app and tell me the problem. this is the error i get on the ...
0 votes
1 answer
791 views

Build runner not working as expected in flutter drift

flutter packages pub run build_runner build --delete-conflicting-outputs the build runner works perfectly for dao files and generates .g.dart files except for the file containing database class and ...
0 votes
1 answer
36 views

Can't assign method to onPressed from Dao delete method

Error: The argument type 'void Function()' can't be assigned to the parameter type 'void Function(BuildContext)?'. Code return Slidable( endActionPane: ActionPane( motion: ScrollMotion(), ...
0 votes
1 answer
486 views

How to make use of the user defined View to pipe data into application with flutter/drift(moor)

I declared some Views following the example in the drift documentation besides database table definitions and managed to go through the generation process. After then I was quite confused as to the ...
2 votes
1 answer
424 views

Flutter Drift(Moor): concat two columns

I have a Table called Contracts: class Contracts extends Table { TextColumn get firstName => text().named('firstname')(); TextColumn get lastName => text().named('lastname')(); // some ...
0 votes
0 answers
321 views

How to create a composite index with Drift?

In SQLite, you can create a composite index and query along multiple fields with that index. Does Drift allow you to do this?
  • 583
0 votes
1 answer
884 views

Flutter: build_runner build command runs indefinitely

i have an old Flutter project. In it i have this error part 'Target of URI hasn't been generated: 'MoorDatabase.g.dart'.Try running the generator that will generate the file referenced by the URI.. So ...
1 vote
0 answers
245 views

How to stop class database file getting created multiple times when using moor?

I'm getting this error: flutter: WARNING (moor): It looks like you've created the database class AppDatabase multiple times. When these two databases use the same QueryExecutor, race conditions will ...
  • 69
0 votes
0 answers
132 views

type convert of long to date time or date in moor database - flutter

I'm receiving long value from Api and I'am trying to create type convertor to convert long values to data time or date. How can I do it?
  • 69
0 votes
0 answers
80 views

How to connect my device to Moor Inspector

I was able to download the Moor inspector plugin, but have no idea how to connect the plugin to my device, which requires Device IP and Port number.
0 votes
2 answers
419 views

Flutter Moor Database: Joining queries proper structure

I have just started to use Moor Database for Flutter. I am going to join my two tables to get some columns from both tables. I have checked the example that is given in docs as follow: // we define a ...
0 votes
1 answer
134 views

Find all rows which match substring, with moor / moor_flutter

I want to select all rows which match a substring with moor / moor_flutter. In SQL, you'd do something like this: 'SELECT * FROM [table] WHERE [field] LIKE '%[substring]%' Is there a 'moor-like' way ...
  • 2,417
1 vote
1 answer
1k views

flutter moor - update specific column in specific row of table

I need to replace a value in specific column of specific row in moor database, but I don't know it's query. can you bring me an example?
  • 148
1 vote
1 answer
332 views

Flutter SQLite get value between 2 dates, one is dynamic ( flutter Moor )

I am building a finance app, created a table called wallets, the wallets table has a column called startDate. using ( flutter_moor ) package for SQLite Now I need to only retrieve the latest created ...
0 votes
2 answers
271 views

How to get aggregated data in moor_flutter?

Let's say I have 2 simple tables Users and Orders: Users has columns Id Orders has columns Id and UserId How do I get all orders of a user easily using moor_flutter and return it as a stream of the ...
  • 1,416
0 votes
1 answer
506 views

How to get the number of entries in a table using flutter_moor?

When I am adding an entry to the table, I need to know the number of elements in the table. onPressed: () { final db = Provider.of<AppDb>(context); final habitCount = 0; /* Number of ...
  • 1,416
0 votes
1 answer
476 views

Result of consuming a Future with future.then() seems to only live inside the .then function()

I am building an app as a project for university and one of the requirements is to play videos within the app. I have links to exercise videos (bicep curls and so on) stored in a column of a table in ...
0 votes
0 answers
375 views

Is there a way to unit test data under moor sqlite db which is in application directory?

Im trying to perform unit testing on moor sqlite db but unable to do it because it tries to fetch the db from path provider(file path) which fails in unit testing file. Mock framework is not working ...
  • 510
0 votes
2 answers
2k views

"Unhandled error Null check operator used on a null value" after await on a Future from a moor database

I am trying to learn how to implement a moor database in flutter and I got stuck getting this error: I/flutter ( 5303): Moor: Sent SELECT * FROM tasks; with args [] E/flutter ( 5303): [ERROR:flutter/...
  • 514
1 vote
1 answer
567 views

Moor Vs ObjectBox: For Complex Flutter DB

For my next flutter project, Please suggest to me, which will be the best option to implement DB Moor or ObjectBox Thanks in advance
1 vote
1 answer
271 views

How to select rows that start with specified letter in Flutter using Moor

I have a table called Items with a column called Name. How can I do a query to get only items that start with a certain letter? For example if I wanted all items that start with words R2. I tried the ...
  • 2,223
0 votes
1 answer
70 views

How to convert sqllite date time into localtime via moor select api

I am building a mobile application using flutter and moor as database library. I have to fetch all transactions for a particular month. My query is like below. Future<List<Transaction>> ...
1 vote
1 answer
744 views

Moor flutter List<MyTable> datatype

I'm using moor_flutter to persist my data in an SQLite database in my Flutter application. One of my columns for the sake of argument looks like this: class Clients extends Table { // Autoincrement ...
0 votes
0 answers
251 views

Flutter: Using moor generated model json factory in chopper converter

I'm using moor as a local storage in my Flutter app, I created the tables, and moor generated the models for me, with a fromJson factory and a toJson method. example: class Addresse extends DataClass ...
  • 623
0 votes
0 answers
638 views

moor build_runner does not create generated file

I have the latest flutter & dart. I create a basic app and then use the getting started code from the moor website: https://moor.simonbinder.eu/docs/getting-started/ When I execute the build ...
0 votes
1 answer
356 views

store list of doubles in moor BlobColumn

I want to use BlobColumn of moor package for storing a list of integer and a list of doubles. I have no trouble saving integer list because blob type in Uint8List. but when I'm storing double list I ...
  • 719
3 votes
2 answers
5k views

Row too big to fit into CursorWindow requiredPos=0, totalRows=1;

I keep hitting this annoying message ! When data finished insert into local database, I saw this message JNI critical lock held for 30.083ms on Thread[27,tid=23883,Runnable,Thread*=0xce150a00,peer=...
  • 12.3k
1 vote
1 answer
571 views

Flutter moor: Got error when adding moor file to make index

I am trying to use flutter moor on my application. So after creating a column: import 'package:moor_flutter/moor_flutter.dart'; @DataClassName("LocationTable") class LocationTables extends ...
2 votes
1 answer
2k views

How to stop class database file getting created multiple times when using flutter_moor?

Whenever I am adding a new row to my database in my flutter app, I am getting this error : WARNING (moor): It looks like you've created the database classAppDatabase multiple times. When these two ...
0 votes
1 answer
701 views

Flutter: Select from two table with distinc in Moor Database

I have query SQL like this: SELECT DISTINCT LST_KURS.LKU_ID, LST_KURS.LKU_SYMBOL FROM LST_PRODUCT_CALC join LST_KURS WHERE LST_PRODUCT_CALC.LKU_ID = LST_KURS.LKU_ID AND LST_PRODUCT_CALC.PSET_ID = #{...
1 vote
0 answers
446 views

Store Complex JSON objects in Local Database Flutter

How can we store an nested JSON object in SQLite database. In Android Room we used to have Embedded and Relation to store and retrieve complex data objects. But in flutter how can we achieve the same? ...
0 votes
1 answer
607 views

flutter: unit testing dao in moor

I've started unit testing the first time. I'm following tutorials of resoCoder here is my test code where I'm mocking my dbManager class but I could not mock DAO's as they are auto-generated in moor ...
2 votes
3 answers
3k views

SQLite bad parameter or other API misuse

Error [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: SqliteException(14): bad parameter or other API misuse, bad parameter or other API misuse (code 21) #0 new DatabaseImpl....
2 votes
2 answers
1k views

Using loosely coupled local data repositories in flutter bloc

This is a what is the best practice kind of a question. I am building an app using flutter and I have the below requirements. I have local (installed on the device) and remote (installed on the ...
0 votes
2 answers
303 views

How to run the setState() after executing insert or delete of the moor in flutter

if you touch the heart icon, I want to insert or delete the product class in the Moor database and change the heart icon to setState() Insertion or deletion is well executed, but the heart icon does ...
0 votes
1 answer
77 views

How can i efficiently query a table entry that matches either of words from Set in moor

I have a Set of String that contains words . The the Set can be of length 15 in average. Am wondering if i can query the entries that contains either these words with moor's operand | efficiently ...
6 votes
4 answers
1k views

Flutter StreamProvider not pushing data into UI

I'm new to flutter. I implemented this sample application to get an idea about SQLite and provider state management. This is a simple task management system. I used MOOR to handle the SQLite database. ...
2 votes
1 answer
1k views

join data from 2 tables into one class

I need some database assistance. I have the following tables: I need to pull out an Event with the data from the EventType Table to assign and Event that has an EventType linked to a User. I am using ...
  • 2,637
1 vote
0 answers
316 views

Moor with bloc authentication

I am developing a Todo flutter app and I am using flutter_moor and bloc and I want to achieve the following in the best and most secure way: Let the user signup. Let the user login after signingup. ...
  • 1,731