streamqflite 0.1.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 20

streamqflite

A reactive stream wrapper around sqflite inspired by sqlbrite.

Getting Started

In your flutter project, add the dependency to your pubspec.yaml

dependencies:
  ...
  streamqflite: 0.1.0

Usage

Import streamqflite.dart

import 'package:streamqflite/streamqflite.dart';

Wrap your database in a StreamDatabase.

var streamDb = StreamDatabase(db);

You can then listen to a query

var singleQuery = streamDb.createQuery("MyTable", where: 'id = ?', whereArgs: [id])
    .mapToOne((row) => MyEntry(row));

var singleOrQuery = streamDb.createQuery("MyTable", where: 'id = ?', whereArgs: [id])
    .mapToOneOrDefault((row) => MyEntry(row), MyEntry.empty());

var listQuery = streamDb.createQuery("MyTable", where: 'name LIKE ?', whereArgs: [query])
    .mapToList((row) => MyEntry(row));

var flexibleQuery = streamDb.createQuery("MyTable", where: 'name LIKE ?', whereArgs: [query])
    .asyncMap((query) => {
        // query is lazy, this lets you not even execute it if you don't need to.
        if (condition) {
            return query();
        } else {
            return Stream.empty();
        }
    }).map((rows) {
        // Do something with all the rows.
        return ...;
    });

These queries will run once to get the current data, then again whenever the given table is modified though the StreamDatabase.

[0.1.0] - TODO: Add release date.

  • Initial Release

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  streamqflite: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:streamqflite/streamqflite.dart';
  
Version Uploaded Documentation Archive
0.1.0 Jul 1, 2018 Go to the documentation of streamqflite 0.1.0 Download streamqflite 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
40
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
20
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.35 <2.0.0