open method

Future<Database> open (
  1. String name,
  2. {int? version,
  3. void onUpgradeNeeded(
    1. VersionChangeEvent event
    ),
  4. void onBlocked(
    1. Event event
    )}
)

Implementation

Future<Database> open(String name,
    {int? version,
    void onUpgradeNeeded(VersionChangeEvent event)?,
    void onBlocked(Event event)?}) {
  if ((version == null) != (onUpgradeNeeded == null)) {
    return new Future.error(new ArgumentError(
        'version and onUpgradeNeeded must be specified together'));
  }
  try {
    OpenDBRequest request;
    if (version != null) {
      request = _open(name, version);
    } else {
      request = _open(name);
    }

    if (onUpgradeNeeded != null) {
      request.onUpgradeNeeded.listen(onUpgradeNeeded);
    }
    if (onBlocked != null) {
      request.onBlocked.listen(onBlocked);
    }
    return _completeRequest(request);
  } catch (e, stacktrace) {
    return new Future.error(e, stacktrace);
  }
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.13.0/dart-indexed_db/IdbFactory/open.html