Skip to content
pubscout

idb_shim

2.11.3, released 11 days ago by tekartik.com

Cross-platform IndexedDB implementation for Dart and Flutter.

WASM-readyRock solid
$ flutter pub add idb_shim
Source repository

What it does

Provides a browser-compatible IndexedDB API that works on the web (real IndexedDB), Dart VM (IO via sembast), and in-memory for tests. It exposes standard IndexedDB concepts like databases, transactions, object stores, indexes, and key ranges.

AI-written summary of version 2.11.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need structured, transactional storage and indexed queries across multiple platforms including the web.
  • You want IndexedDB-compatible semantics outside the browser for unit testing your database schema and access.

Skip it when

  • You prefer an ORM or a simpler key-value/SQL abstraction where you do not want to deal directly with IndexedDB database upgrades and transactions.

Strengths

  • Cross-platform support (Web, Dart VM, mobile, desktop).
  • Mirrors native IndexedDB semantics allowing easy code sharing.
  • Provides in-memory factories for fast unit testing.

Weaknesses

  • Requires manual handling of schema migrations inside onUpgradeNeeded callbacks.
  • IO implementation over Sembast has some limitations compared to native browser IndexedDB.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
6
import 'package:idb_shim/idb.dart';
import 'package:idb_shim/idb_browser.dart';

Future<void> main() async {
  final factory = getIdbFactory();
  final db = await factory.open(
    'my_database',
    version: 1,
    onUpgradeNeeded: (VersionChangeEvent e) {
      final db = e.database;
      if (!db.objectStoreNames.contains('users')) {
        db.createObjectStore('users', autoIncrement: true);
      }
    },
  );
  final txn = db.transaction('users', idbModeReadWrite);
  final store = txn.objectStore('users');
  await store.add({'name': 'Alice'});
  await txn.completed;
}

Alternatives

Packages that do the same job and could replace idb_shim.

  • hive_ce

    If you want a lightweight and fast key-value database box without dealing with IndexedDB or SQLite schemas.

  • sqflite

    If you prefer traditional SQLite relational databases for mobile platforms instead of an IndexedDB shim.

Works with

Packages commonly used together with idb_shim: ones it builds on, ones built on it, and its own family.