get<T> static method

T get<T>(
  1. BuildContext context,
  2. String name
)

Returns the custom style registered under name via the styles:custom hook, cast to T.

T can be any style type — TextStyle, ButtonStyle, InputDecoration, BoxDecoration, or any other type a plugin chooses to register.

Throws a TypeError at runtime if the resolved value cannot be cast to T.

final style = AppCustomStyles.get<TextStyle>(context, 'promo_badge');
final card  = AppCustomStyles.get<BoxDecoration>(context, 'card_elevated');

Implementation

static T get<T>(BuildContext context, String name) =>
    MooseScope.hookRegistryOf(context)
        .execute<dynamic>(
          'styles:custom',
          <String, dynamic>{'name': name, 'context': context},
        ) as T;