2

I have an abstract class named AbstractFoo and its implementation, Foo. Foo also implements an interface Bar. I would like to make Foo disposable so I assume that I need to implement Disposable class but I am getting an error

Classes and mixins can only implement other classes and mixins

I tried to make AbstractFoo implement Disposable but I get the same error. Can anyone help?

Gerhard
  • 22,678
  • 7
  • 27
  • 43
Themelis
  • 4,048
  • 2
  • 21
  • 45

1 Answers1

2

There is no automatic disposal system built into Dart. You are referencing the w_common package.

According to the page you linked, you will need to define classes you want to be disposed something like this:

class MyDisposable extends Object with Disposable {
   MyDisposable() {
     var thing = new ThingThatRequiresCleanup();
     getManagedDisposer(() {
       thing.cleanUp();
       return new Future(() {});
     });
   }
 }

For more specific help, please edit your question to include code.

Chuck Batson
  • 2,165
  • 1
  • 17
  • 15
  • 2
    I've been working so much I haven't event noticed that I've been referencing that package. Thanks – Themelis Jan 11 '23 at 20:54