ReplaceablePot<T> class

A variant of Pot with the replace method that allows its factory to be replaced.

This type of pot is created through either Pot.replaceable or Pot.pending.

// replace() is not available in this pot.
final pot = Pot(() => Counter());

// replace() is available in these pots.
final replaceablePot1 = Pot.replaceable(() => Counter());
final replaceablePot2 = Pot.pending<Counter>();

...

replaceablePot2.replace(() => SubtypeOfCounter());

replaceForTesting is available on this type of Pot regardless of the flag status of Pot.forTesting.

Inheritance
Annotations
  • @sealed

Properties

hashCode int
The hash code for this object.
no setterinherited
hasObject bool
Whether an object has been created by the factory and still exists.
no setterinherited
isPending bool
Whether the pot is in the pending state.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scope int?
The index number of the scope that the object of this pot has been bound to.
no setterinherited

Methods

call({bool suppressWarning = false}) → T
Returns the object of type T created by the factory.
inherited
create({bool suppressWarning = false}) → void
Calls the factory to create an object of type T.
inherited
dispose() → void
Discards resources in the pot.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyObjectUpdate() → void
Notifies the listeners of an update of the object in the pot.
inherited
replace(PotObjectFactory<T> factory) → void
Replaces the factory in a replaceable pot with a new one, and/or creates a new object using the new factory.
replaceForTesting(PotObjectFactory<T> factory) → void
Replaces the factory set in the constructor with a new one, and/or creates a new object using the new factory, for testing purposes.
inherited
reset() → void
Discards the object of type T that was created by the factory and has been held in the pot.
inherited
resetAsPending() → void
Calls reset and also removes the existing factory to switch the state of the ReplaceablePot to pending.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited