maybeLocaleOf method Null safety

Locale? maybeLocaleOf(
  1. BuildContext context
)

The locale of the Localizations widget for the widget tree that corresponds to BuildContext context.

If no Localizations widget is in scope then this function will return null.

Implementation

static Locale? maybeLocaleOf(BuildContext context) {
  assert(context != null);
  final _LocalizationsScope? scope = context.dependOnInheritedWidgetOfExactType<_LocalizationsScope>();
  return scope?.localizationsState.locale;
}