我有一个名为 AbstractFoo
的抽象类及其实现 Foo
。 Foo
还实现了一个接口(interface) Bar
。我想让 Foo 成为一次性的,所以我假设我需要实现 Disposable类,但我收到错误
Classes and mixins can only implement other classes and mixins
我尝试让 AbstractFoo
实现 Disposable
但我得到了同样的错误。有人可以帮忙吗?
最佳答案
Dart 中没有内置自动处理系统。您正在引用 w_common package .
根据您链接的页面,您需要定义要处理的类,如下所示:
class MyDisposable extends Object with Disposable {
MyDisposable() {
var thing = new ThingThatRequiresCleanup();
getManagedDisposer(() {
thing.cleanUp();
return new Future(() {});
});
}
}
如需更具体的帮助,请编辑您的问题以包含代码。
关于dart - 如何在 Dart 中使对象成为一次性对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75087720/