getDependencies method
Returns context
-based dependencies.
It's recommended to use InheritedProperties.get instead of obtaining dependencies from BuildContext for performance reason.
// avoid doing this:
final direction = Directionality.of(context);
// do this:
final direction = resolved.get<TextDirection>();
Implementation
Iterable<dynamic> getDependencies(BuildContext context) {
return [
CssWhitespace.normal,
Directionality.maybeOf(context) ?? TextDirection.ltr,
DefaultTextStyle.of(context).style,
// performance critical
// avoid adding broad dependencies like MediaQuery.of(context)
// because it may invalidate our root properties too often
// TODO: remove lint ignore when our minimum Flutter version >= 3.10
// ignore: deprecated_member_use
TextScaleFactor(MediaQuery.textScaleFactorOf(context)),
];
}