Handschrift class
An extended TextStyle that supports additional style variants for bold and link text.
Handschrift (Dutch for "handwriting") extends Flutter's TextStyle to provide built-in support for common text style variations used in rich text rendering. This allows a single style definition to carry information about how bold and linked text should be rendered.
This class is particularly useful when you need consistent bold or link styling that can be easily accessed via the bold and link getters, which merge the respective variant styles with the base style.
Example
final style = Handschrift(
fontSize: 16,
color: Colors.black,
boldStyle: TextStyle(fontWeight: FontWeight.bold),
linkStyle: TextStyle(color: Colors.blue, decoration: TextDecoration.underline),
);
// Use the bold variant
Text('Bold text', style: style.bold);
// Use the link variant
Text('Click here', style: style.link);
Creating from an existing TextStyle
Use Handschrift.fromTextStyle to convert an existing TextStyle:
final baseStyle = TextStyle(fontSize: 14);
final handschrift = Handschrift.fromTextStyle(
baseStyle,
boldStyle: TextStyle(fontWeight: FontWeight.w700),
);
Animation Support
Handschrift supports smooth interpolation via the lerp method, which interpolates all properties including the bold and link variants.
- Inheritance
- Available extensions
Constructors
-
Handschrift({bool inherit = true, Color? color, Color? backgroundColor, double? fontSize, FontWeight? fontWeight, FontStyle? fontStyle, double? letterSpacing, double? wordSpacing, TextBaseline? textBaseline, double? height, TextLeadingDistribution? leadingDistribution, Locale? locale, Paint? foreground, Paint? background, List<
Shadow> ? shadows, List<FontFeature> ? fontFeatures, List<FontVariation> ? fontVariations, TextDecoration? decoration, Color? decorationColor, TextDecorationStyle? decorationStyle, double? decorationThickness, String? debugLabel, String? fontFamily, List<String> ? fontFamilyFallback, String? package, TextOverflow? overflow, TextStyle? boldStyle, TextStyle? linkStyle}) -
Creates a Handschrift with the given properties.
const
- Handschrift.fromTextStyle(TextStyle style, {TextStyle? boldStyle, TextStyle? linkStyle})
-
Creates a Handschrift from an existing TextStyle.
factory
Properties
- background → Paint?
-
The paint drawn as a background for the text.
finalinherited
- backgroundColor → Color?
-
The color to use as the background for the text.
finalinherited
- bold → TextStyle
-
Returns this style merged with
_boldStyle.no setter - color → Color?
-
The color to use when painting the text.
finalinherited
- debugLabel → String?
-
A human-readable description of this text style.
finalinherited
- decoration → TextDecoration?
-
The decorations to paint near the text (e.g., an underline).
finalinherited
- decorationColor → Color?
-
The color in which to paint the text decorations.
finalinherited
- decorationStyle → TextDecorationStyle?
-
The style in which to paint the text decorations (e.g., dashed).
finalinherited
- decorationThickness → double?
-
The thickness of the decoration stroke as a multiplier of the thickness
defined by the font.
finalinherited
- fontFamily → String?
-
The name of the font to use when painting the text (e.g., Roboto).
finalinherited
-
fontFamilyFallback
→ List<
String> ? -
The ordered list of font families to fall back on when a glyph cannot be
found in a higher priority font family.
no setterinherited
-
fontFeatures
→ List<
FontFeature> ? -
A list of FontFeatures that affect how the font selects glyphs.
finalinherited
- fontSize → double?
-
The size of fonts (in logical pixels) to use when painting the text.
finalinherited
- fontStyle → FontStyle?
-
The typeface variant to use when drawing the letters (e.g., italics).
finalinherited
-
fontVariations
→ List<
FontVariation> ? -
A list of FontVariations that affect how a variable font is rendered.
finalinherited
- fontWeight → FontWeight?
-
The typeface thickness to use when painting the text (e.g., bold).
finalinherited
- foreground → Paint?
-
The paint drawn as a foreground for the text.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
The height of this text span, as a multiple of the font size.
finalinherited
- inherit → bool
-
Whether null values in this TextStyle can be replaced with their value
in another TextStyle using merge.
finalinherited
- leadingDistribution → TextLeadingDistribution?
-
How the vertical space added by the height multiplier should be
distributed over and under the text.
finalinherited
- letterSpacing → double?
-
The amount of space (in logical pixels) to add between each letter.
A negative value can be used to bring the letters closer.
finalinherited
- link → TextStyle
-
Returns this style merged with
_linkStyle.no setter - locale → Locale?
-
The locale used to select region-specific glyphs.
finalinherited
- overflow → TextOverflow?
-
How visual text overflow should be handled.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
shadows
→ List<
Shadow> ? -
A list of Shadows that will be painted underneath the text.
finalinherited
- textBaseline → TextBaseline?
-
The common baseline that should be aligned between this text span and its
parent text span, or, for the root text spans, with the line box.
finalinherited
- wordSpacing → double?
-
The amount of space (in logical pixels) to add at each sequence of
white-space (i.e. between each word). A negative value can be used to
bring the words closer.
finalinherited
Methods
-
apply(
{Color? color, Color? backgroundColor, TextDecoration? decoration, Color? decorationColor, TextDecorationStyle? decorationStyle, double decorationThicknessFactor = 1.0, double decorationThicknessDelta = 0.0, String? fontFamily, List< String> ? fontFamilyFallback, double fontSizeFactor = 1.0, double fontSizeDelta = 0.0, int fontWeightDelta = 0, FontStyle? fontStyle, double letterSpacingFactor = 1.0, double letterSpacingDelta = 0.0, double wordSpacingFactor = 1.0, double wordSpacingDelta = 0.0, double heightFactor = 1.0, double heightDelta = 0.0, TextBaseline? textBaseline, TextLeadingDistribution? leadingDistribution, Locale? locale, List<Shadow> ? shadows, List<FontFeature> ? fontFeatures, List<FontVariation> ? fontVariations, String? package, TextOverflow? overflow}) → TextStyle -
Creates a copy of this text style replacing or altering the specified
properties.
inherited
-
compareTo(
TextStyle other) → RenderComparison -
Describe the difference between this style and another, in terms of how
much damage it will make to the rendering.
inherited
-
copyWith(
{bool? inherit, Color? color, Color? backgroundColor, double? fontSize, FontWeight? fontWeight, FontStyle? fontStyle, double? letterSpacing, double? wordSpacing, TextBaseline? textBaseline, double? height, TextLeadingDistribution? leadingDistribution, Locale? locale, Paint? foreground, Paint? background, List< Shadow> ? shadows, List<FontFeature> ? fontFeatures, List<FontVariation> ? fontVariations, TextDecoration? decoration, Color? decorationColor, TextDecorationStyle? decorationStyle, double? decorationThickness, String? debugLabel, String? fontFamily, List<String> ? fontFamilyFallback, String? package, TextOverflow? overflow, TextStyle? boldStyle, TextStyle? linkStyle}) → Handschrift -
Creates a copy of this Handschrift with the given fields replaced.
override
-
debugFillProperties(
DiagnosticPropertiesBuilder properties, {String prefix = ''}) → void -
Adds all properties prefixing property names with the optional
prefix.inherited -
getParagraphStyle(
{TextAlign? textAlign, TextDirection? textDirection, TextScaler textScaler = TextScaler.noScaling, String? ellipsis, int? maxLines, TextHeightBehavior? textHeightBehavior, Locale? locale, String? fontFamily, double? fontSize, FontWeight? fontWeight, FontStyle? fontStyle, double? height, StrutStyle? strutStyle}) → ParagraphStyle -
The style information for paragraphs, encoded for use by
dart:ui.inherited -
getTextStyle(
{double textScaleFactor = 1.0, TextScaler textScaler = TextScaler.noScaling}) → TextStyle -
The style information for text runs, encoded for use by
dart:ui.inherited -
lerp(
Handschrift? other, double t) → Handschrift -
Linearly interpolates between this Handschrift and
other.override -
merge(
TextStyle? other) → TextStyle -
Returns a new text style that is a combination of this style and the given
otherstyle.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toHandschrift(
{TextStyle? boldStyle, TextStyle? linkStyle}) → Handschrift -
Available on TextStyle, provided by the TextStyleX extension
Converts this TextStyle to a Handschrift. -
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringShort(
) → String -
A brief description of this object, usually just the runtimeType and the
hashCode.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited