streamqflite 1.0.0

  • Readme
  • Changelog
  • Installing
  • 74

streamqflite #

Pub

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.2.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

// Emits a single row, doesn't emit if the row dosen't exist.
Stream<MyEntry> singleQuery = streamDb.createQuery("MyTable", where: 'id = ?', whereArgs: [id])
    .mapToOne((row) => MyEntry(row));

// Emits a single row, or the given default value if the row doesn't exist.
Stream<MyEntry> singleOrDefaultQuery = streamDb.createQuery("MyTable", where: 'id = ?', whereArgs: [id])
    .mapToOneOrDefault((row) => MyEntry(row), MyEntry.empty());

// Emits a list of rows.
Stream<List<MyEntry>> 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: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub 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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
46
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1
  • Flutter: 1.17.3

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:streamqflite/streamqflite.dart, package:sqflite/sqflite.dart]

Package does not support Flutter platform web

Because of import path [package:streamqflite/streamqflite.dart, package:sqflite/sqflite.dart]

Package does not support Flutter platform windows

Because of import path [package:streamqflite/streamqflite.dart, package:sqflite/sqflite.dart]

Package not compatible with SDK dart

because of import path [streamqflite]

Maintenance suggestions

Package is getting outdated. (-42.74 points)

The package was last published 74 weeks ago.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and streamqflite.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-1 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.61.0 <3.0.0
flutter 0.0.0
sqflite ^1.0.0 1.3.1
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.0
path 1.7.0
sky_engine 0.0.99
sqflite_common 1.0.2+1
synchronized 2.2.0+1
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_driver
flutter_test
mockito ^3.0.1