castInstance method
T
castInstance(
- dynamic instance
Cast instance
to this type, throwing if the cast fails.
This is similar to the as
language operator:
// Before
final castInstance = instance as String;
// After
final castInstance = stringType.castInstance(instance);
Implementation
T castInstance(dynamic instance) => instance as T;