26

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.

user2864740
  • 57,407
  • 13
  • 129
  • 202
Dongyu Jia
  • 337
  • 1
  • 3
  • 6
  • If you are using angular-dart, DetachAware can help you. Implement your component from DetachAware and override detach method. – ashokd Aug 21 '15 at 18:18

1 Answers1

28

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

Community
  • 1
  • 1
Günter Zöchbauer
  • 558,509
  • 191
  • 1,911
  • 1,506