objectdb_flutter 0.0.3

  • README.md
  • Example
  • Installing
  • Versions
  • new44


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] - TODO: Add release date.

  • TODO: Describe initial release.


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

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support 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:objectdb_flutter/objectdb_flutter.dart';
Version Uploaded Documentation Archive
0.0.3 Sep 20, 2018 Go to the documentation of objectdb_flutter 0.0.3 Download objectdb_flutter 0.0.3 archive
0.0.1 Aug 30, 2018 Go to the documentation of objectdb_flutter 0.0.1 Download objectdb_flutter 0.0.1 archive
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 Sep 20, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.3
  • Flutter: 0.8.4


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


The description is too short.

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Package is pre-v0.1 release.

While there is nothing inherently wrong with versions of 0.0.*, it usually means 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.5
Transitive dependencies
collection 1.14.11
deeply 1.0.1
execution_queue 1.0.2
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies