runtime_type
1.1.0, released 3 years ago by an unverified publisher
Provides a non‑opaque RuntimeType object for runtime type checks and casting.
What it does
RuntimeType wraps a generic type so you can pass type information around at runtime. It enables subtype checking, type checks, and calling functions with type arguments dynamically.
AI-written summary of version 1.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to inspect or compare types at runtime beyond what Dart's Type offers
- You want to pass type information to generic functions or callbacks
- You need to call functions with type arguments dynamically
Skip it when
- The static type system already solves your problem
- Performance‑critical code where extra indirection is undesirable
- You rely on dart:mirrors or other reflection mechanisms
Strengths
- Enables runtime subtype checks without mirrors
- Simple API based on generics
- Adds extensions for calling functions with RuntimeType arguments
Weaknesses
- Limited to Dart; not a full reflection solution
- May not handle all complex generic scenarios
- Adds a small runtime overhead
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
final stringType = RuntimeType<String>();
bool isSubtype = <int>[] is List<num>; // example of underlying trickAlternatives
Packages that do the same job and could replace runtime_type.
- antlr4
Dart runtime libraries for ANTLR 4 parser generator.
50Compare - result_type
A Result type representing success or failure in Dart
50Compare - convert
Encoders and decoders for converting between different data representations.
50Compare - telegram_web_app
Flutter wrapper for Telegram Web App JavaScript APIs on web platforms
45Compare
Works with
Packages commonly used together with runtime_type: ones it builds on, ones built on it, and its own family.