public static List <LocalizationsDelegate> _delegatesOf(BuildContext context) { D.assert(context != null); _LocalizationsScope scope = (_LocalizationsScope)context.inheritFromWidgetOfExactType(typeof(_LocalizationsScope)); D.assert(scope != null, "a Localizations ancestor was not found"); return(new List <LocalizationsDelegate>(scope.localizationsState.widget.delegates)); }
public static T of <T>(BuildContext context, Type type) { D.assert(context != null); D.assert(type != null); _LocalizationsScope scope = (_LocalizationsScope)context.inheritFromWidgetOfExactType(typeof(_LocalizationsScope)); if (scope != null && scope.localizationsState != null) { return(scope.localizationsState.resourcesFor <T>(type)); } return(default);
public static Locale localeOf(BuildContext context, bool nullOk = false) { D.assert(context != null); _LocalizationsScope scope = (_LocalizationsScope)context.inheritFromWidgetOfExactType(typeof(_LocalizationsScope)); if (nullOk && scope == null) { return(null); } D.assert((bool)(scope != null), "a Localizations ancestor was not found"); return(scope.localizationsState.locale); }
public static Locale localeOf(BuildContext context, bool nullOk = false) { D.assert(context != null); _LocalizationsScope scope = (_LocalizationsScope)context.dependOnInheritedWidgetOfExactType <_LocalizationsScope>(); if (nullOk && scope == null) { return(null); } D.assert((bool)(scope != null), () => "a Localizations ancestor was not found"); return(scope.localizationsState.locale); }