MyClass({this.maybeStr, this.maybeList, this.maybeMap});
MyClass cloneWithOverrides({ OptionalNullable<String> maybeStr = const OptionalNullable.undefined(), OptionalNullable<List<int>> maybeList = const OptionalNullable.undefined(), OptionalNullable<Map<String, String>> maybeMap = const OptionalNullable.undefined(), }) { return MyClass( maybeStr: maybeStr.or(this.maybeStr), maybeList: maybeList.or(this.maybeList), maybeMap: maybeMap.or(this.maybeMap), ); } }
main() { final orig = MyClass( maybeStr: null, maybeList: [1, 2, 3], maybeMap: {‘door’: ‘wood’, ‘window’: ‘glass’}, ); final mod = orig.cloneWithOverrides( maybeStr: Some(‘a string’), maybeMap: None(), ); assert(mod.maybeStr == ‘a string’); assert(mod.maybeList!.length == 3); assert(mod.maybeMap == null); }
Implementers
Initialize an OptionalNullable to an undefined state. The value of an OptionalNullable is considered “undefined” until overridden by assigning it to Some or None. const
The hash code for this object.
read-onlyinherited
True if the value is Some or None.
read-only
True if the value is not Some or None.
read-only
A representation of the runtime type of the object.
read-onlyinherited
Invoked when a non-existent method or property is accessed.
inherited
If the value is Some, the value is returned. If None, null is returned. Otherwise, the value isUndefined, in which case the given fallback value is returned instead.
A string representation of this object.
inherited
The equality operator.
inherited