getDependencies method

Iterable getDependencies(
  1. BuildContext context
)
inherited

Returns context-based dependencies.

Includes these by default:

Use TextStyleHtml.getDependency to get value by type.

// in normal widget building:
final scale = MediaQuery.of(context).textScaleFactor;
final color = Theme.of(context).accentColor;

// in build ops:
final scale = tsh.getDependency<MediaQueryData>().textScaleFactor;
final color = tsh.getDependency<ThemeData>().accentColor;

It's recommended to use values from TextStyleHtml instead of obtaining from BuildContext for performance reason.

// avoid doing this:
final widgetValue = Directionality.of(context);

// do this:
final buildOpValue = tsh.textDirection;

Implementation

Iterable<dynamic> getDependencies(BuildContext context) => [
      MediaQuery.of(context),
      Directionality.of(context),
      DefaultSelectionStyle.of(context),
      DefaultTextStyle.of(context).style,
      SelectionContainer.maybeOf(context),
      Theme.of(context),
    ];