of static method

WidgetsLocalizations of(
  1. BuildContext context
)

The WidgetsLocalizations from the closest Localizations instance that encloses the given context.

This method is just a convenient shorthand for: Localizations.of<WidgetsLocalizations>(context, WidgetsLocalizations)!.

References to the localized resources defined by this class are typically written in terms of this method. For example:

textDirection: WidgetsLocalizations.of(context).textDirection,

Implementation

static WidgetsLocalizations of(BuildContext context) {
  assert(debugCheckHasWidgetsLocalizations(context));
  return Localizations.of<WidgetsLocalizations>(context, WidgetsLocalizations)!;
}