type_plus
2.1.1, released 3 years ago by schultek.dev
Utility for introspecting and manipulating Dart types at runtime.
What it does
Provides extensions to obtain a type's name, unique id, base type, and arguments. Allows registering custom types, creating types from ids, and checking type inheritance.
AI-written summary of version 2.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to decompose generic types or retrieve type metadata at runtime.
- You want to invoke generic functions dynamically with type arguments.
Skip it when
- You require compile‑time code generation for type safety.
- You need a full dependency‑injection or state‑management solution.
Strengths
- Works with any Dart platform without additional build steps.
- Supports custom type ids and dynamic generic invocation.
Weaknesses
- Relies on runtime registration of custom types.
- No code‑generation; type safety is limited to runtime checks.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
void main() {
TypePlus.add<MyClass>(id: 'CoolId');
Type t = TypePlus.fromId('CoolId');
print(t.name); // MyClass
}Alternatives
Packages that do the same job and could replace type_plus.
- result_type
A Result type representing success or failure in Dart
50Compare - exception_templates
Generic Dart exception and error classes for throwing and catching custom exceptions by type argument.
70Compare - anyhow
Dart implementation of Rust's Result monad type and anyhow crate for error handling.
45Compare
Works with
Packages commonly used together with type_plus: ones it builds on, ones built on it, and its own family.