DefaultTextStyle class

An inherited widget that sets the default TextStyle for descendant Text and RichText widgets.

Retrieve via DefaultTextStyle.of. If no DefaultTextStyle ancestor exists, returns a default TextStyle().

Inheritance

Constructors

DefaultTextStyle({Key? key, required TextStyle style, required Widget child})
Creates a DefaultTextStyle that provides style to descendants.
const

Properties

child Widget
The widget below this inherited widget in the tree.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
style TextStyle
The default text style for descendant Text widgets.
final

Methods

createElement() InheritedElement
Creates the Element for this widget.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
updateShouldNotify(covariant DefaultTextStyle oldWidget) bool
Whether descendant widgets should rebuild when style changes.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

maybeOf(BuildContext context) TextStyle
Returns the TextStyle from the closest DefaultTextStyle ancestor, or null if none exists.
of(BuildContext context) TextStyle
Returns the TextStyle from the closest DefaultTextStyle ancestor, or a default TextStyle() if none exists.