tailor
tailor

Reputation: 443

How to create live streambuilder from sqflite database in flutter?

I have local database of sqflite. And I had set future list of database by below method.

Future<List<Message>> messageList() async {
    final List<Map<String, dynamic>> maps = await _db!.query('Test',orderBy: 'timestamp DESC',);
    return List.generate(maps.length, (i) {
      return Message(
          inboxId: maps[i]['inboxId'],
          messageId: maps[i]['messageId'],
          sticker: maps[i]['sticker']
      );
    }
    );
  }

But I want create stream builder of this database for updating listview every time on CRUD operation ?

Upvotes: 0

Views: 1202

Answers (1)

Nijat Namazzade
Nijat Namazzade

Reputation: 742

If you are facing that issue, SQLite will not work in terms of updating your data with StreamBuilder.

If you want this functionality, I recommend you to use Moor library for that.

Unfortunately, the moor is not available on pub.dev.

Note: Moor has been renamed to drift : https://pub.dev/packages/drift

dependencies:
  drift: ^2.2.0

Upvotes: 0

Related Questions