idb_shim 1.4.2

  • Installing
  • Versions
  • 58

idb shim

Pure dart indexed db like API on top of native, websql or memory implementation. Its goal is to support browsers that do not support the indexed_db api with very few changes.

It also allows to test your database schema and access in vm unit tests.

Build Status


Assume you have the existing:

import 'dart:indexed_db';, version: xxx, onUpgradeNeeded: yyy);

This can be replaced by:

import 'package:idb_shim/idb_browser.dart'
IdbFactory idbFactory = getIdbFactory();, version: xxx, onUpgradeNeeded: yyy);

All other existing code remains unchanged. Simple example below:

// define the store name
const String storeName = "records";

// open the database
Database db = await"my_records.db", version: 1,
    onUpgradeNeeded: (VersionChangeEvent event) {
  Database db = event.database;
  // create the store
  db.createObjectStore(storeName, autoIncrement: true);

// put some data
var txn = db.transaction(storeName, "readwrite");
var store = txn.objectStore(storeName);
var key = await store.put({"some": "data"});
await txn.completed;

// read some data
txn = db.transaction(storeName, "readonly");
store = txn.objectStore(storeName);
Map value = await store.getObject(key);
await txn.completed;



Testing with dartdevc

pub serve test --web-compiler=dartdevc --port=8079
pub run test -p chrome --pub-serve=8079

Known limitations/issues

Memory/Io/WebSql implementation

  • For autoincrement, if key is set, it cannot be set as a different type than int
  • Nextunique and prevunique not support (for now)
  • No support for Cursor.source
  • No generic support for blocked. It is always possible to upgrade the database, however other tabs will get blocked in their future calls
  • Blocked and onVersionChange event support, this is actually tricky for websql, actually the new db won't be blocked but the old one will! so the proper common implementation is to register for onVersionChange event and when receiving simply reload the page. Sample code to come
  • Index.get: only by key is supported (no range yet)
  • WebSql implementation issue SqlResultSet.rows.first is not working in dart2js (bug?)
Type of data
  • Only stuff that can be JSON serialized/deserialized
  • DateTime is not supported, it should be converted to string using toIso8601String
  • Cyclic dependecy are not supported (per JSON serialization)
  • Large float are not converted to int (native indexeddb implementation does this)
Type of key
  • String and num (double and int) are supported
  • DateTime is not supported, convert them to String
  • No support for compound index

Native exception

  • Native exception type have no match in dart so a custom DatabaseError object is created to wrap the exception

Ie limitation

IE 11, Edge 12 has the following limitations:

  • no support for reading objectStore.autoIncrement properties
  • ObjectStore.count() without argument throw a 'DataError' exception...better avoid count() on IE...
  • it seems ie close the transaction 'sooner' then chrome/firefox, i.e. calling an sync function that wrap an idb calls makes the transaction terminate
  • IDBIndex.multiEntry not supported on ie

Safari limitation

Safari has the following limitations (as of v 9.0)

  • no support for transactions on multiple stores
  • very short transaction life cycle (no await on sdk 1.12)


  • Add implicit-cast: false support


  • Depends on sembast 1.4.0


  • Add IdbFactory.cmp


  • Simulate multistore transaction on Safari


  • Add support for import/export (sembast export format)
  • Fix timing to mimic IE limitation
  • Add workaround for transaction bug in sdk 1.13


  • Fix implementation for IE/Edge where the transaction life-cycle is shorter


  • Add support for ObjectStore.deleteIndex


  • Fix openCursor for Index that included null key before (sembast)
  • Travis test integration


  • Initial revision

Use this package as a library

1. Depend on it

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

  idb_shim: "^1.4.2"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

      import 'package:idb_shim/idb.dart';

      import 'package:idb_shim/idb_browser.dart';

      import 'package:idb_shim/idb_client.dart';

      import 'package:idb_shim/idb_client_memory.dart';

      import 'package:idb_shim/idb_client_native.dart';

      import 'package:idb_shim/idb_client_sembast.dart';

      import 'package:idb_shim/idb_client_websql.dart';

      import 'package:idb_shim/idb_console.dart';

      import 'package:idb_shim/idb_io.dart';

      import 'package:idb_shim/utils/idb_import_export.dart';

      import 'package:idb_shim/utils/idb_utils.dart';
Version Uploaded Documentation Archive
1.4.2 Mar 1, 2018 Go to the documentation of idb_shim 1.4.2 Download idb_shim 1.4.2 archive
1.4.1 Feb 26, 2018 Go to the documentation of idb_shim 1.4.1 Download idb_shim 1.4.1 archive
1.4.0 Jun 27, 2017 Go to the documentation of idb_shim 1.4.0 Download idb_shim 1.4.0 archive
1.3.7 Jun 20, 2017 Go to the documentation of idb_shim 1.3.7 Download idb_shim 1.3.7 archive
1.3.5 Dec 15, 2015 Go to the documentation of idb_shim 1.3.5 Download idb_shim 1.3.5 archive
1.3.4 Nov 24, 2015 Go to the documentation of idb_shim 1.3.4 Download idb_shim 1.3.4 archive
1.3.3 Nov 24, 2015 Go to the documentation of idb_shim 1.3.3 Download idb_shim 1.3.3 archive
1.3.2 Nov 12, 2015 Go to the documentation of idb_shim 1.3.2 Download idb_shim 1.3.2 archive
1.3.1 Nov 6, 2015 Go to the documentation of idb_shim 1.3.1 Download idb_shim 1.3.1 archive
1.3.0 Oct 27, 2015 Go to the documentation of idb_shim 1.3.0 Download idb_shim 1.3.0 archive

All 35 versions...


We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
22 / 100
Code health derived from static analysis. [more]
99 / 100
Reflects how tidy and up-to-date the package is. [more]
85 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: web

Platform components identified in package: html, js.


  • Homepage does not exists.

    We were unable to access at the time of the analysis.

  • Use constrained dependencies.

    The pubspec.yaml contains 4 dependencies without version constraints. Specify version ranges for the following dependencies: collection, js, path, sembast.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 7 hints.

    Strong-mode analysis of lib/idb_client_native.dart failed with the following error:

    line: 99 col: 34
    The method 'getDatabaseNames' isn't defined for the class 'IdbFactory'.

    Strong-mode analysis of lib/src/common/common_value.dart gave the following hint:

    line: 12 col: 10
    'JSON' is deprecated and shouldn't be used.

    Similar analysis of the following files failed:

    • lib/src/sembast/sembast_database.dart (hint)
    • lib/src/websql/websql_database.dart (hint)
    • lib/src/websql/websql_object_store.dart (hint)
  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use idb_shim.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.24.0 <2.0.0
collection >=1.4.0 1.14.10
js any 0.6.1
path any 1.6.0
sembast >=1.6.1 1.8.0 1.9.0-dev.1
Transitive dependencies
dart2_constant 1.0.1+dart2
synchronized 1.5.0+1
Dev dependencies
browser any
dev_test any
logging any 0.11.3+1
stack_trace any
test any