dispose method

void dispose()

Implementation

void dispose()
{
  // remove listeners
  removeAllListeners();

  // dispose of datasources
  if (datasources != null)
  for (var datasource in datasources!) if (datasource.parent == this) datasource.dispose();
  datasources?.clear();

  // remove model and all of its bindables from the scope
  scope?.unregisterModel(this);

  // dispose of children
  if (children != null)
  {
    children!.forEach((child) => child.dispose());
    children!.clear();
  }
}