Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:indexed_db
dart:indexed_db
description

dart:indexed_db library

A client-side key-value store with support for indexes.

Note

This core library is deprecated, and scheduled for removal in late 2025.It has been replaced bypackage:web.Themigration guide has more details.

IndexedDB is a web standard API for client-side storage ofstructured data. By storing data on the client in an IndexedDB,apps can get advantages such as faster performance andpersistence.

In IndexedDB, each record is identified by a unique index or key,making data retrieval speedy.You can store structured data,such as images, arrays, and maps using IndexedDB.The standard does not specify size limits for individual data itemsor for the database itself, but browsers may impose storage limits.

Using indexed_db

The classes in this library provide an interfaceto the browser's IndexedDB, if it has one.To use this library in your code:

import 'dart:indexed_db';

IndexedDB is almost universally supported in modern web browsers, buta web app can determine if the browser supports IndexedDBwithIdbFactory.supported:

if (IdbFactory.supported)  // Use indexeddb.else  // Find an alternative.

Access to the browser's IndexedDB is provided by the app's top-levelWindow object, which your code can refer to withwindow.indexedDB.So, for example,here's how to use window.indexedDB to open a database:

Future open() {  return window.indexedDB.open('myIndexedDB',      version: 1,      onUpgradeNeeded: _initializeDatabase)    .then(_loadFromDB);}void _initializeDatabase(VersionChangeEvent e) {  ...}Future _loadFromDB(Database db) {  ...}

All data in an IndexedDB is stored within anObjectStore.To manipulate the database useTransactions.

Other resources

Other options for client-side data storage include:

  • Window.localStorage—abasic mechanism that stores data as aMap,and where both the keys and the values are strings.

MDN providesAPIdocumentation.

Classes

Cursor
CursorWithValue
Database
An indexed database object for storing client-side datain web apps.
IdbFactory
Index
KeyRange
ObjectStore
Observation
Observer
ObserverChanges
OpenDBRequest
Request
Transaction
VersionChangeEvent

Typedefs

ObserverCallback= void Function(ObserverChangeschanges)
  1. Dart
  2. dart:indexed_db
DartSDK
  1. Libraries
  2. Core
  3. dart:async
  4. dart:collection
  5. dart:convert
  6. dart:core
  7. dart:developer
  8. dart:math
  9. dart:typed_data
  10. VM
  11. dart:ffi
  12. dart:io
  13. dart:isolate
  14. dart:mirrors
  15. Web
  16. package:webopen_in_new
  17. dart:js_interop
  18. dart:js_interop_unsafe
  19. Web (Legacy)
  20. dart:html
  21. dart:indexed_db
  22. dart:js
  23. dart:js_util
  24. dart:svg
  25. dart:web_audio
  26. dart:web_gl
dart:indexed_db library

[8]ページ先頭

©2009-2025 Movatter.jp