FlexibleKey class
A flexible key class that supports up to 20 independent Object
fields.
This class is designed to represent a composite key, where each objectX
field can hold any type of object. It is suitable for use cases like
cache keys, map keys, or other scenarios where a combination of multiple
values is needed to form a unique identifier.
object1
toobject20
: These fields can hold any object type, such asString
,int
,DateTime
, or custom objects.- The
==
operator andhashCode
method ensure correct equality comparison and hash generation based on all non-null fields. - The
toString()
method concatenates all non-null fields into a human-readable string, joined by underscores (_
), for easy debugging.
Example usage:
- Comparing two identical keys:
var key1 = FlexibleKey('user', 123, 'profile');
var key2 = FlexibleKey('user', 123, 'profile');
print(key1 == key2); // Output: true
- Comparing two different keys:
var key1 = FlexibleKey('user', 123, 'profile');
var key3 = FlexibleKey('user', 456, 'profile');
print(key1 == key3); // Output: false
Constructors
- FlexibleKey.new(Object? object1, [Object? object2 = _sentinelValue, Object? object3 = _sentinelValue, Object? object4 = _sentinelValue, Object? object5 = _sentinelValue, Object? object6 = _sentinelValue, Object? object7 = _sentinelValue, Object? object8 = _sentinelValue, Object? object9 = _sentinelValue, Object? object10 = _sentinelValue, Object? object11 = _sentinelValue, Object? object12 = _sentinelValue, Object? object13 = _sentinelValue, Object? object14 = _sentinelValue, Object? object15 = _sentinelValue, Object? object16 = _sentinelValue, Object? object17 = _sentinelValue, Object? object18 = _sentinelValue, Object? object19 = _sentinelValue, Object? object20 = _sentinelValue])
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- object1 → Object?
-
final
- object10 → Object?
-
final
- object11 → Object?
-
final
- object12 → Object?
-
final
- object13 → Object?
-
final
- object14 → Object?
-
final
- object15 → Object?
-
final
- object16 → Object?
-
final
- object17 → Object?
-
final
- object18 → Object?
-
final
- object19 → Object?
-
final
- object2 → Object?
-
final
- object20 → Object?
-
final
- object3 → Object?
-
final
- object4 → Object?
-
final
- object5 → Object?
-
final
- object6 → Object?
-
final
- object7 → Object?
-
final
- object8 → Object?
-
final
- object9 → Object?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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.
override