of method Null safety

TextSelectionThemeData of(
  1. BuildContext context
)

Returns the data from the closest TextSelectionTheme ancestor. If there is no ancestor, it returns ThemeData.textSelectionTheme. Applications can assume that the returned value will not be null.

Typical usage is as follows:

TextSelectionThemeData theme = TextSelectionTheme.of(context);

Implementation

static TextSelectionThemeData of(BuildContext context) {
  final TextSelectionTheme? selectionTheme = context.dependOnInheritedWidgetOfExactType<TextSelectionTheme>();
  return selectionTheme?.data ?? Theme.of(context).textSelectionTheme;
}