completed 属性
提供将来会完成的对象,当事务完成后。
如果在事务中发生错误或事务被中止,此将来将会引发错误。
实现
Future<Database> get completed {
var completer = new Completer<Database>();
this.onComplete.first.then((_) {
completer.complete(db);
});
this.onError.first.then((e) {
completer.completeError(e);
});
this.onAbort.first.then((e) {
// Avoid completing twice if an error occurs.
if (!completer.isCompleted) {
completer.completeError(e);
}
});
return completer.future;
}