runtime_type library
A non-opaque representation of types at runtime.
Normally, Type
objects are opaque and cannot be used for actual logic. RuntimeType
allows for operations such as sub- or super-type checking, type checks, and casting using a variable instead of a literal.
To use, replace your type literals with calls to the RuntimeType
constructor:
// Before
final stringType = String;
// After
final stringType = RuntimeType<String>();
Classes
-
RuntimeType<
T> - A non-opaque representation of a Type that can be used at runtime.
Extensions
- RuntimeTypeX on Object?
- Provides extensions to allow RuntimeTypes appear more similar to the core Dart language.
Constants
-
boolType
→ const RuntimeType<
bool> -
The
bool
type represented as a RuntimeType. -
doubleType
→ const RuntimeType<
double> -
The
double
type represented as a RuntimeType. - dynamicType → const RuntimeType
-
The
dynamic
type, represented as a RuntimeType. -
enumType
→ const RuntimeType<
Enum> -
The
enum
type, represented as a RuntimeType. -
intType
→ const RuntimeType<
int> -
The
int
type, represented as a RuntimeType. -
neverType
→ const RuntimeType<
Never> -
The
never
type, represented as a RuntimeType. -
nullType
→ const RuntimeType<
Null> -
The
Null
type, represented as a RuntimeType. -
numType
→ const RuntimeType<
num> -
The
num
type, represented as a RuntimeType. -
objectType
→ const RuntimeType<
Object> -
The
object
type, represented as a RuntimeType. -
stringType
→ const RuntimeType<
String> -
The
string
type, represented as a RuntimeType.