dispose method
void
dispose()
disposes of the model releasing resources and removing bindings
Implementation
void dispose() {
// remove listeners
removeAllListeners();
// dispose of datasources
datasources?.forEach((datasource) =>
datasource.parent == this ? datasource.dispose() : null);
datasources?.clear();
// remove model and all of its bindables from the scope
scope?.unregisterModel(this);
// dispose of all children
children?.forEach((child) => child.dispose());
children?.clear();
// dispose of the local scope
if (isLocalScope) scope?.dispose();
// dispose of the sub-scope
_subscope?.dispose();
}