getDependencies method

  1. @override
Iterable getDependencies (
  1. BuildContext context
)

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

@override
Iterable<dynamic> getDependencies(BuildContext context) =>
    [...super.getDependencies(context), Theme.of(context)];