objectdb_flutter 0.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

objectdb_flutter #

Reactive ObjectDB helper.

CAUTION This plugin is still in development. Use at your own risk. If you notice any bugs you can create an issue on GitHub. You're also welcome to contribute using pull requests. Please open an issue before spending time on any pull request.

Subscribe to store inside widget to keep the view up-to-date.

See example for implementation and ObjectDB for general db API.

[0.0.1] - Initial release

  • Flutter ObjectDB (embedded document-oriented NoSQL database) -listener with reactive store


import 'dart:io';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart' as path;
import 'package:objectdb_flutter/objectdb_flutter.dart';

// declare db object
ObjectDB db;

void main() async {
  // get document directory using path_provider plugin
  Directory appDocDir = await path.getApplicationDocumentsDirectory();

  String dbFilePath = [appDocDir.path, 'user.db'].join('/');

  // delete old database file if exists
  File dbFile = File(dbFilePath);

  // check if database already exists
  var isNew = !await dbFile.exists();
  if (!isNew) dbFile.deleteSync();
  // initialize and open database
  db = ObjectDB(dbFilePath);

  // insert sample data
      'name': {'first': 'Alex', 'last': 'Boyle'},
      'message': 'abc',
      'active': true,
      'count': 0,
      'name': {'first': 'Maia', 'last': 'Herzog'},
      'message': 'def',
      'active': true,
      'count': 0,
      'name': {'first': 'Curtis', 'last': 'Smith'},
      'message': 'ghi',
      'active': true,
      'count': 0,
      'name': {'first': 'Jaquelin', 'last': 'Renner'},
      'message': 'jkl',
      'active': false,
      'count': 0,
      'name': {'first': 'Denis', 'last': 'Swift'},
      'message': 'mno',
      'active': true,
      'count': 0,
      'name': {'first': 'Anna', 'last': 'Metz'},
      'message': 'pqr',
      'active': true,
      'count': 0,
      'name': {'first': 'Malinda', 'last': 'Reynolds'},
      'message': 'stu',
      'active': false

  // simulate insert/update/delete
  int i = 0;
  new Timer.periodic(Duration(seconds: 2), (Timer t) {
      'name': {'first': 'Malinda', 'last': 'Reynolds'},
      'message': 'hoho ' + i.toString(),
      'active': i % 2 == 0,
      'count': i++

    if (i > 10) i = 0;

  new Timer.periodic(Duration(seconds: 10), (Timer t) {
      Op.gte: {'count': 5}
    }, {
      Op.set: {'message': 'updated'}

  new Timer.periodic(Duration(seconds: 15), (Timer t) {
    db.remove({'message': 'updated'});


class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ObjectDB Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      home: MyHomePage(title: 'ObjectDB Demo Page'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage>
    with StoreWatcherMixin<MyHomePage> {
  Store contacts;

  void initState() {


  void init() async {
    contacts = await listenToStore(db, {'active': true});

  void dispose() async {
    await db.close();

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: contacts == null // check if _contacts has been initialized
          ? Center(
              child: Text('loading...'),
          : ListView(
                  contacts.map((contact) => contactItem(contact)).toList(),

// creates list tile with contact info
Widget contactItem(Map contact) {
  return ListTile(
    title: Text(contact['name']['first'] + ' ' + contact['name']['last']),
    subtitle: Text(contact['message']),

Use this package as a library

1. Depend on it

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

  objectdb_flutter: ^0.0.4

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:objectdb_flutter/objectdb_flutter.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

Package is getting outdated. (-10.41 points)

The package was last published 57 weeks ago.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.0.0 <3.0.0
flutter 0.0.0
objectdb ^1.0.5 1.0.7+1
Transitive dependencies
collection 1.14.11 1.14.12
deeply 1.0.1
execution_queue 1.0.2
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies