extension<T> method Null safety

T? extension<T>()

Used to obtain a particular ThemeExtension from extensions.

Obtain with Theme.of(context).extension<MyThemeExtension>().

See extensions for an interactive example.

Implementation

T? extension<T>() => extensions[T] as T;