Skip to content
pubscout

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.

WASM-ready
$ flutter pub add runtime_type
Source repository

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 trick

Alternatives

Packages that do the same job and could replace runtime_type.

Works with

Packages commonly used together with runtime_type: ones it builds on, ones built on it, and its own family.