of static method

Provides access to the nearest LocalizationManager up the widget tree.

Throws FlutterError if no LocalizationProvider is found in the widget tree, ensuring that usage of the localization functionalities cannot proceed without a properly configured provider.

context The build context which will be used to look up the LocalizationProvider.

Implementation

static LocalizationManager of(BuildContext context) {
  final LocalizationProvider? result =
      context.dependOnInheritedWidgetOfExactType<LocalizationProvider>();
  if (result == null) {
    throw FlutterError('LocalizationProvider not found in context');
  }
  return result.localizationManager;
}