of method
Obtain the current translation using inherited
.
Implementation
@override
I18N of(
BuildContext context, {
bool defaultToGlobal = false,
}) {
try {
return injected.of(
context,
defaultToGlobal: defaultToGlobal,
);
} catch (e) {
final widget = context.widget;
if (widget is TopStatelessWidget) {
throw ('No Parent InheritedWidget of type [TopStatelessWidget] is found.\n'
'There are several ways to avoid this problem. The simplest is to '
'use a Builder to get a context that is "under" the [TopReactiveStateless].\n'
'A more efficient solution is to split your build function into several widgets. This '
'introduces a new context from which you can obtain the [TopReactiveStateless].\n'
'${context.describeElement('The context used was')}');
}
throw ('No Parent InheritedWidget of type [TopReactiveStateless ] is found.\n'
'Make sure to use [TopReactiveStateless] widget on top of MaterialApp '
'Widget.\n'
'${context.describeElement('The context used was')}');
}
}