PlatformText class Class
Main class for platform_text package.
PlatformText returns Text or SelectableText widget depending on the platform it's running on.
Native → Text
Web → SelectableText
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- PlatformText
Constructors
- PlatformText(String data, {Key? key, TextStyle? style, StrutStyle? strutStyle, TextAlign? textAlign, TextDirection? textDirection, double? textScaleFactor, int? maxLines, String? semanticsLabel, TextHeightBehavior? textHeightBehavior, TextWidthBasis? textWidthBasis, Locale? locale, bool? softWrap, TextOverflow? overflow, FocusNode? focusNode, bool showCursor = false, bool autofocus = false, ToolbarOptions? toolbarOptions, int? minLines, double cursorWidth = 2.0, double? cursorHeight, Radius? cursorRadius, Color? cursorColor, BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight, BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight, DragStartBehavior dragStartBehavior = DragStartBehavior.start, bool enableInteractiveSelection = true, TextSelectionControls? selectionControls, GestureTapCallback? onTap, ScrollPhysics? scrollPhysics, SelectionChangedCallback? onSelectionChanged, @visibleForTesting bool webTest = false})
-
Creates a PlatformText text widget.
const
- PlatformText.rich(TextSpan textSpan, {Key? key, FocusNode? focusNode, TextStyle? style, StrutStyle? strutStyle, TextAlign? textAlign, TextDirection? textDirection, double? textScaleFactor, bool showCursor = false, bool autofocus = false, ToolbarOptions? toolbarOptions, int? minLines, int? maxLines, double cursorWidth = 2.0, double? cursorHeight, Radius? cursorRadius, Color? cursorColor, BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight, BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight, DragStartBehavior dragStartBehavior = DragStartBehavior.start, bool enableInteractiveSelection = true, TextSelectionControls? selectionControls, GestureTapCallback? onTap, ScrollPhysics? scrollPhysics, String? semanticsLabel, TextHeightBehavior? textHeightBehavior, TextWidthBasis? textWidthBasis, SelectionChangedCallback? onSelectionChanged, Locale? locale, bool? softWrap, TextOverflow? overflow, @visibleForTesting bool webTest = false})
-
Creates a platform text widget with a InlineSpan.
const
Properties
- autofocus → bool
-
Whether this text field should focus itself if nothing else is already
focused.
final
- cursorColor → Color?
-
The color to use when painting the cursor.
final
- cursorHeight → double?
-
How tall the cursor will be.
final
- cursorRadius → Radius?
-
How rounded the corners of the cursor should be.
final
- cursorWidth → double
-
How thick the cursor will be.
final
- data → String?
-
The text to display.
final
- dragStartBehavior → DragStartBehavior
-
Determines the way that drag start behavior is handled.
final
- enableInteractiveSelection → bool
-
Whether to enable user interface affordances for changing the
text selection.
final
- focusNode → FocusNode?
-
Defines the focus for this widget.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- locale → Locale?
-
Used to select a font when the same Unicode character can
be rendered differently, depending on the locale.
final
- maxLines → int?
-
An optional maximum number of lines for the text to span, wrapping if necessary.
If the text exceeds the given number of lines, it will be truncated according
to overflow.
final
- minLines → int?
-
The minimum number of lines to occupy when the content spans fewer lines.
final
- onSelectionChanged → SelectionChangedCallback?
-
Called when the user changes the selection of text (including the cursor
location).
final
- onTap → GestureTapCallback?
-
Called when the user taps on this selectable text.
final
- overflow → TextOverflow?
-
How visual overflow should be handled.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollPhysics → ScrollPhysics?
-
The ScrollPhysics to use when vertically scrolling the input.
final
- selectionControls → TextSelectionControls?
-
Optional delegate for building the text selection handles.
final
- selectionEnabled → bool
-
Same as enableInteractiveSelection.
no setter
- selectionHeightStyle → BoxHeightStyle
-
Controls how tall the selection highlight boxes are computed to be.
final
- selectionWidthStyle → BoxWidthStyle
-
Controls how wide the selection highlight boxes are computed to be.
final
- semanticsLabel → String?
-
{@template flutter.widgets.Text.semanticsLabel}
An alternative semantics label for this text.
final
- showCursor → bool
-
Whether to show cursor.
final
- softWrap → bool?
-
Whether the text should break at soft line breaks.
final
- strutStyle → StrutStyle?
-
The strut style to use. Strut style defines the strut, which sets minimum
vertical layout metrics.
final
- style → TextStyle?
-
If non-null, the style to use for this text.
final
- textAlign → TextAlign?
-
How the text should be aligned horizontally.
final
- textDirection → TextDirection?
-
The directionality of the text.
final
- textHeightBehavior → TextHeightBehavior?
-
Defines how to apply TextStyle.height over and under text.
final
- textScaleFactor → double?
-
The number of font pixels for each logical pixel.
final
- textSpan → TextSpan?
-
The text to display as a TextSpan.
final
- textWidthBasis → TextWidthBasis?
-
Defines how to measure the width of the rendered text.
final
- toolbarOptions → ToolbarOptions
-
Configuration of toolbar options.
final
- webTest → bool
-
Only for UTs
final
Methods
-
build(
BuildContext context) → Widget -
Build method with logic responsible for returnig proper widget depends on running platform.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
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
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited