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.
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.
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://mcmap.net/q/450397/-how-do-we-delete-an-object-in-dart and https://github.com/dart-lang/sdk/issues/3691
I don't know if this is relevant, but Flutter provides dispose method, which works similar to a deconstructor, it lets you dispose any object or instance methods, e.g.
just override this method after your build method to dispose any methods.
© 2022 - 2024 — McMap. All rights reserved.