Baggage class

Immutable Baggage that stores entries with unique string keys.

Baggage is immutable. Adding or removing entries returns a new instance. The specification states that if an entry is added with a key that already exists, it MUST overwrite the existing entry.

Annotations
  • @immutable

Constructors

Baggage.fromJson(Map<String, dynamic> json)
Creates a baggage instance from a JSON representation. JSON format must be: { key: { value: string, metadata?: string } }
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
isEmpty bool
Returns true if this Baggage contains no entries.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith(String key, String value, [String? metadata]) Baggage
Returns a new Baggage with the given key-value pair added (or replaced).
copyWithBaggage(Baggage moreBaggage) Baggage
Creates a new Context adding in moreBaggage, replacing any existing keys that are the same as the keys in moreBaggage
copyWithout(String key) Baggage
Returns a new Baggage with the given key removed (if it exists).
getAllEntries() Map<String, BaggageEntry>
Returns all entries in this Baggage as an immutable map.
getAllValues() List<String>
Retrieves all Baggage values for the given key, or null if not present.
getEntry(String key) BaggageEntry?
Retrieves a BaggageEntry for the given key, or null if not present.
getValue(String key) String?
Retrieves a Baggage value for the given key, or null if not present.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts the baggage to a JSON representation.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override
operator [](String key) String?
Operator overload for getting a value