Nest<T> class
final
A generic wrapper class that circumnavigates the limitation of nullable types.
Some libraries explicitly expect some parameters to be of type T?
, usually
because null
means the type was not initialized yet.
Think of a previous
value of an observable which still holds its initial
value.
If T
is nullable (e.g. int?
), then it will be unclear whether null
means that the previous state was actually null
, or whether there was
no previous state. This is because nullable types cannot be nested,
i.e. T?? == T?
.
Therefore, int??
is the same as int?
in the given example.
Instead of using the type T
directly, we can wrap T
with a Nest.
In the example above, we can replace the generic type int?
with
Nest<int?>
. The above previous
getter/field has now type Nest<int?>?
,
which makes it trivial to distinguish between present null value
and absent value.
Constructors
- Nest(T v)
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- v → T
-
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited