Kind<T> class abstract

Describes how to construct an instance of some type T.

Fixed-width types

Variable-width types

Nullable types and collections

Custom objects

Implementers
Annotations
  • @immutable

Constructors

Kind.constructor({required String? name, String? jsonName, List<Trait>? traits, List<T>? examples})
Constructor for subclasses.
const

Properties

dartType Type
Type T.
no setter
defaultValueMirror InstanceMirror
InstanceMirror for the default value.
no setter
equality → Equality
Equality for the kind;
no setter
examples Iterable<T>
Examples of instances that are valid (isValidDynamic).
no setter
examplesThatAreInvalid Iterable<T>
Examples of instances that are NOT valid (isValidDynamic).
no setter
examplesWithoutValidation Iterable<T>
Interesting examples of instances (may be valid or invalid).
no setter
hashCode int
The hash code for this object.
no setteroverride
isNullable bool
Whether this kind is nullable.
no setter
isPrimitive bool
Whether instances of the kind can't have references to other instances.
no setter
jsonName String?
JSON identifier of the class.
final
name String
Dart identifier of the class.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
traits List<Trait>
Traits of the kind.
final

Methods

asType(Object? value) → T
Casts value to T.
checkDeclaration() → void
Checks that the declaration makes sense.
checkInstance(Object? value) → void
checkValid(T instance) → void
checkValidDynamic(Object? instance) → void
Throws ArgumentError error if instance is not valid (isValidDynamic).
clone(T instance) → T
Clones the instance.
compare(T left, T right) int
Compares two values.
debugString(T instance) String
Constructs a string for debugging instance.
decodeJsonTree(Object? json) → T
Converts json (any JSON tree) to an instance of T.
decodeString(String string) → T
Decodes string to an instance of T.
encodeJsonTree(T instance) Object?
Converts instance to a JSON tree.
encodeString(T instance) String
Converts instance to a string.
isDefaultValue(Object? instance) bool
Determines whether the argument is a default value of this kind.
isInstance(Object? instance) bool
Determines whether the argument is an instance of T.
isInstanceOfList(Object? instance) bool
Determines whether the argument is an instance of List<T>.
isInstanceOfSet(Object? instance) bool
Determines whether the argument is an instance of Set<T>.
isNullableSubKind(Kind other, {bool andNotEqual = true}) bool
Tells whether the argument is instance of Kind<T> and dartType values are different.
isSubKind(Kind other, {bool andNotEqual = true}) bool
Tells whether the argument is instance of Kind<T> and dartType values are different.
isValid(T instance) bool
Tells whether the instance is valid.
isValidDynamic(Object? instance) bool
Tells whether the instance is valid.
memorySize(T instance) int
Estimates memory usage of instance.
memorySizeWith(MemoryCounter counter, T instance) → void
Estimates memory usage with an instance of MemoryCounter.
newInstance() → T
Constructs a new instance of the default value.
newList(int length, {bool growable = true}) List<T>
Constructs a new list.
newListFrom(Iterable<T> iterable, {bool growable = true}) List<T>
Constructs a new list from iterable.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
permute(T instance) → T
Generates another instance with some deterministic function.
register() → void
Registers this kind so that it will be visible in Kind.all.
toList() Kind<List<T>>
Constructs Kind for List<T>.
toNonNullable() Kind<T>
Returns a non-nullable kind.
toNullable() Kind<T?>
Constructs Kind for T?.
toPolymorphic() PolymorphicKind<T>
Constructs a PolymorphicKind for this kind.
toSet() Kind<Set<T>>
Constructs Kind for Set<T>.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override

Static Properties

all Set<Kind>
All registered kinds.
final

Static Methods

find<T>({T? instance}) Kind<T>
Finds a registered kind for T.
maybeFindByInstance<T>(T instance) Kind<T>?
Finds a registered kind for instance.
maybeFindByType<T>() Kind<T>?
Finds a registered kind for T.
newInvalidValueError({required Kind kind, required Object? instance}) Error
Used by checkValidDynamic.
registerAll(Iterable<Kind> kinds) → void
Registers all kinds.

Constants

defaultPrimitiveKinds → const List<Kind>
Default primitive kinds.
forBigInt → const Kind<BigInt>
Kind for BigInt.
forBool → const Kind<bool>
Kind for bool.
forDateTime → const Kind<DateTime>
Kind for DateTime.
forDouble → const Kind<double>
Kind for double.
forDuration → const Kind<Duration>
Kind for Duration.
forInt → const Kind<int>
Kind for int.
forKindInDebugMode → const PolymorphicKind<Kind>
Kind for Kind.
forNull → const Kind<Null>
Kind for Null (null).
forString → const Kind<String>
Kind for String.
forUint8List → const Kind<Uint8List>
Kind for Uint8List.