Optional<T> class
Copyright (c) 2026 Netmera Research.
Immutable optional value: distinguishes "not set" from "set to null".
- Optional.of — value is present
- Optional.absent — explicitly no value (e.g. set to null)
- A field being
null(no Optional at all) means "never set"
Constructors
- Optional.absent()
-
Optional with no value (explicitly set to null).
factory
- Optional.fromNullable(T? value)
-
From nullable: null → absent, non-null → of.
factory
- Optional.of(T value)
-
Optional containing the given
value(must not be null; use absent for null).factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isPresent → bool
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- valueOrNull → T?
-
The value if present, otherwise null.
no setter
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