reactive_sqldb

reactive_sqldb is a powerful SQLite manager that lets you:

  • Create dynamic tables at runtime with custom fields.
  • Define relational links using foreign keys.
  • Perform standard CRUD operations.
  • Listen to reactive table updates via Streams β€” no manual refresh needed.

Pub Package

  1. Reactive Queries

  • Query data and listen to changes automatically.
  • Offline local database support both IOS and Android.
  • Advanced create relationship tables.
  1. CRUD Operations

  • Create: Insert single or multiple rows.
  • Read: Query rows with filters, sorting, and limits.
  • Update: Update rows efficiently with where conditions.
  • Delete: Remove rows with conditions.
  1. SQL Flexibility

  • Full SQLite syntax support for advanced queries.
  • Use raw queries if needed alongside reactive queries.
  • Supports joins, grouping, and aggregations.

Usage

Make sure to check out examples

Install and Import

Add the following line to pubspec.yaml:

    dependencies:
        reactive_sqldb: ^1.0.6
import 'package:reactive_sqldb/fields.dart';
import 'package:reactive_sqldb/reactive_sqldb.dart';

Using

Init Datatabase

 final _reactiveSqldbPlugin = ReactiveSqldb(name: "mytesting.db");

Watch tables

Stream<List<Map<String, dynamic>>> watchTable(String table){}

Example:

///Listen Tables
_reactiveSqldbPlugin.watchTable("users").listen((rows) {
      print('Rows: $rows');
});

Query with a condition:

  1. Function 1
Future<Map<String, Object?>?> get(
    String table,
    Map<String, Object?> whereArgs,
  ) 

Example:

var user = await _reactiveSqldbPlugin.get("user", {
    "email": "[email protected]",
});
  • This fetches one rows or filtered rows based on whereArgs.
  1. Function 2
 Future<List<Map<String, Object?>>> getAll(
    String table,
    Map<String, Object?>? whereArgs, {
    int? limit,
    int? offset = 0
    })

Example:

 var userAll = await _reactiveSqldbPlugin.getAll(
      "user",
      {},
      offset: 0,
      limit: 20,
    );
  • This fetches all or filtered rows based on whereArgs.
  • limit : end query (optional)
  • offset : start query (optional)
  1. Function 3
 Future<List<Map<String, dynamic>>> query(
    String table, {
    required String? where,
    required List<dynamic>? args,
    int? limit,
    int? offset = 0,
  }) 

Example:

var userAllQuery = await _reactiveSqldbPlugin.query(
      "user",
      where: 'name = ? AND email = ?',
      args: ["David", '[email protected]'],
      offset: 0,
      limit: 10,
);
  • This fetches all or filtered rows based on args.
  • limit : end query (optional)
  • offset : start query (optional)

Insert record

 Future<int> insert(String table, Map<String, dynamic> record) async {}

Example:

await _reactiveSqldbPlugin.insert("user", {
      "name": "David",
      "email": "[email protected]",
      "gennder": "Male",
});

Update record by id

 Future<void> update(String table, int id, Map<String, dynamic> record) async { }

Example:

await _reactiveSqldbPlugin.update("user", 1, {
      "name": "David 1",
      "email": "[email protected]",
});

Delete record by id

Future<void> delete(String table, int id) async { }

Example:


await _reactiveSqldbPlugin.delete("user", 1);

Delete by query

 Future<void> updateQuery(
    String table,
    Map<String, dynamic> record,
    Map<String, dynamic> whereArgs,
  ) async { }

Example:

 await _reactiveSqldbPlugin.updateQuery(
      'users',
      {'name': "Updated", "email": "[email protected]"},
      {'id': 1},
    );

Raw SQL

Manange query data by your Raw SQL.

  1. Query
 Future<void> raw(
    String sql, {
    List<Object?>? arguments,
    String? notifyTableName,
  })
  • Insert
await raw(
  'INSERT INTO users (id, name, email) VALUES (?, ?, ?)',
  arguments: [1, 'Darith', '[email protected]'],
  notifyTableName: 'users',
);
  • Update
await raw(
  'UPDATE users SET email = ? WHERE id = ?',
  arguments: ['[email protected]', 1],
  notifyTableName: 'users',
);

  • Delete
await raw(
  'DELETE FROM users WHERE id = ?',
  arguments: [1],
  notifyTableName: 'users',
);

See all other you can check our documents make sure to check out Documentation Hello everyone πŸ‘‹

If you want to support me, feel free to do so.

THANK YOUR SUPPORT ME !!!

============================================

αžŸαž½αžŸαŸ’αžŠαžΈ αž’αŸ’αž“αž€αž‘αžΆαŸ†αž„αž’αžŸαŸ‹αž‚αŸ’αž“αžΆπŸ‘‹

αž”αžΎβ€‹αž’αŸ’αž“αž€β€‹αž…αž„αŸ‹β€‹αž‚αžΆαŸ†αž‘αŸ’αžšβ€‹αžαŸ’αž‰αž»αŸ† αžŸαžΌαž˜β€‹αž’αŸ’αžœαžΎβ€‹αžŠαŸ„αž™β€‹αžŸαŸαžšαžΈ ,

αžŸαžΌαž˜αž’αžšαž‚αž»αžŽ