open method Null safety

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 {
    var 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);
  }
}