destroy<T extends Object?> method
Destroys the instance and builder of T
type with an id
optional.
If onlyInstance
is true
, ignores to deresgisters the builder.
Returns true
if it was successfully.
Implementation
bool destroy<T extends Object?>({
String? id,
bool onlyInstance = false,
}) {
final reactterInstance = _getReactterInstance<T>(id);
if (reactterInstance?.instance == null && onlyInstance) {
final reactterInstance = ReactterInstance<T>(id);
Reactter.log('The "$reactterInstance" instance already deleted.');
return false;
}
if (reactterInstance != null) {
reactterInstance.refs.clear();
_removeInstance<T>(reactterInstance);
}
if (onlyInstance) return true;
return unregister<T>(id);
}