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