maybeOf method Null safety
- BuildContext context
The text direction from the closest instance of this class that encloses the given context.
If there is no Directionality ancestor widget in the tree at the given context, then this will return null.
Typical usage is as follows:
TextDirection? textDirection = Directionality.maybeOf(context);
See also:
- of, which will throw if no Directionality ancestor widget is in the tree.
Implementation
static TextDirection? maybeOf(BuildContext context) {
final Directionality? widget = context.dependOnInheritedWidgetOfExactType<Directionality>();
return widget?.textDirection;
}