Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do something before object destruction in Dart?

Tags:

In Java we can do something like override finalize(), in C++ we can do something like ~Someclass(),

But How can I do it in dart, I read the doc in https://www.dartlang.org/ but did not find answers.

like image 984
Dongyu Jia Avatar asked Jul 27 '15 05:07

Dongyu Jia


People also ask

How do you destroy objects in darts?

You don't need to actively delete objects in Dart. Dart is a garbage-collected language, so any object that you don't hold any references to will eventually be garbage collected and freed by the runtime system. So all you have to do is to clear any variables you have that reference the object.

Does Dart have destructor?

There is nothing like a destructor in Dart. JS garbage collector doesn't provide a way to implement this.


1 Answers

This is not supported. There is nothing like a destructor in Dart.
JS garbage collector doesn't provide a way to implement this. See also https://stackoverflow.com/a/20490161/217408 and https://github.com/dart-lang/sdk/issues/3691

like image 188
Günter Zöchbauer Avatar answered Oct 29 '22 05:10

Günter Zöchbauer