of static method

TextStyle of(
  1. BuildContext context
)

Returns the TextStyle from the closest DefaultTextStyle ancestor, or a default TextStyle() if none exists.

Implementation

static TextStyle of(BuildContext context) {
  final widget =
      context.dependOnInheritedWidgetOfExactType<DefaultTextStyle>();
  if (widget != null) {
    return widget.style;
  }
  return const TextStyle();
}