typed<T> method

  1. @Deprecated('Use future.then((v) => v as T) instead.')
Future<T> typed <T>(Future future)
@Deprecated('Use future.then((v) => v as T) instead.')

Creates a wrapper which throws if future's value isn't an instance of T.

This soundly converts a Future to a Future<T>, regardless of its original generic type, by asserting that its value is an instance of T whenever it's provided. If it's not, the future throws a CastError.

Implementation

@Deprecated('Use future.then((v) => v as T) instead.')
static Future<T> typed<T>(Future future) =>
    future is Future<T> ? future : future.then((v) => v as T);