copyWith method
Returns a copy of this object with its field values replaced by the ones provided to this method.
Since bridge
, hueNetwork
, additionalInfo
, and json
are nullable,
they are defaulted to an empty object in this method. If left as empty
objects, their current values in this FailedResource object will be
used. This way, if they are null
, the program will know that they are
intentionally being set to null
.
Implementation
FailedResource copyWith({
ResourceType? type,
String? id,
Object? bridge = sentinelValue,
Object? hueNetwork = sentinelValue,
ErrorType? error,
Object? additionalInfo = sentinelValue,
Object? json = sentinelValue,
}) {
if (!identical(bridge, sentinelValue)) {
assert(bridge is Bridge?, '`bridge` must be a `Bridge?` object');
}
if (!identical(hueNetwork, sentinelValue)) {
assert(hueNetwork is HueNetwork?,
'`hueNetwork` must be a `HueNetwork?` object');
}
if (!identical(additionalInfo, sentinelValue)) {
assert(additionalInfo is String?, '`additionalInfo` must be a `String?`');
}
if (!identical(json, sentinelValue)) {
assert(json is Map<String, dynamic>?,
'`json` must be a `Map<String, dynamic>?` object');
}
return FailedResource(
type: type ?? this.type,
id: id ?? this.id,
bridge: identical(bridge, sentinelValue)
? this.bridge?.copyWith()
: bridge as Bridge?,
hueNetwork: identical(hueNetwork, sentinelValue)
? this.hueNetwork
: hueNetwork as HueNetwork?,
error: error ?? this.error,
additionalInfo: identical(additionalInfo, sentinelValue)
? this.additionalInfo
: additionalInfo as String?,
json: identical(json, sentinelValue)
? this.json == null
? null
: Map<String, dynamic>.from(this.json!)
: json as Map<String, dynamic>?,
);
}