of static method
- 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 throw a descriptive FlutterError in debug mode and an exception in release mode.
Typical usage is as follows:
TextDirection textDirection = Directionality.of(context);
See also:
- maybeOf, which will return null if no Directionality ancestor widget is in the tree.
Implementation
static TextDirection of(BuildContext context) {
assert(debugCheckHasDirectionality(context));
final Directionality widget = context.dependOnInheritedWidgetOfExactType<Directionality>()!;
return widget.textDirection;
}