FitReadMore class

A customizable Flutter widget that provides "read more" and "read less" functionality for long text content with support for annotations, styling, and trimming options.

Inheritance

Constructors

FitReadMore(String data, {Key? key, ValueNotifier<bool>? isCollapsed, String? preDataText, String? postDataText, TextStyle? preDataTextStyle, TextStyle? postDataTextStyle, String trimExpandedText = 'show less', String trimCollapsedText = 'read more', Color? colorClickableText, int trimLength = 240, int trimLines = 2, TrimMode trimMode = TrimMode.length, TextStyle? moreStyle, TextStyle? lessStyle, String delimiter = '$_kEllipsis ', TextStyle? delimiterStyle, List<FitAnnotation>? annotations, bool isExpandable = true, TextStyle? style, StrutStyle? strutStyle, TextAlign? textAlign, TextDirection? textDirection, Locale? locale, bool? softWrap, TextOverflow? overflow, TextScaler? textScaler, String? semanticsLabel, TextWidthBasis? textWidthBasis, TextHeightBehavior? textHeightBehavior, Color? selectionColor, VoidCallback? onExpanded, VoidCallback? onCollapsed})
Creates a FitReadMore widget with plain text.
const
FitReadMore.rich(TextSpan richData, {Key? key, TextSpan? richPreData, TextSpan? richPostData, ValueNotifier<bool>? isCollapsed, String trimExpandedText = 'show less', String trimCollapsedText = 'read more', Color? colorClickableText, int trimLength = 240, int trimLines = 2, TrimMode trimMode = TrimMode.length, TextStyle? moreStyle, TextStyle? lessStyle, String delimiter = '$_kEllipsis ', TextStyle? delimiterStyle, bool isExpandable = true, TextStyle? style, StrutStyle? strutStyle, TextAlign? textAlign, TextDirection? textDirection, Locale? locale, bool? softWrap, TextOverflow? overflow, TextScaler? textScaler, String? semanticsLabel, TextWidthBasis? textWidthBasis, TextHeightBehavior? textHeightBehavior, Color? selectionColor, VoidCallback? onExpanded, VoidCallback? onCollapsed})
Creates a FitReadMore widget with rich text.
const

Properties

annotations List<FitAnnotation>?
List of text annotations for pattern matching
final
colorClickableText Color?
Color for clickable text (read more/less)
final
data String?
The text data to display
final
delimiter String
Delimiter text (usually ellipsis)
final
delimiterStyle TextStyle?
Style for delimiter text
final
hashCode int
The hash code for this object.
no setterinherited
isCollapsed ValueNotifier<bool>?
External controller for collapse/expand state
final
isExpandable bool
Whether the text can be expanded/collapsed
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
lessStyle TextStyle?
Style for "read less" text
final
locale Locale?
final
moreStyle TextStyle?
Style for "read more" text
final
onCollapsed VoidCallback?
Callback when text is collapsed
final
onExpanded VoidCallback?
Callback when text is expanded
final
overflow TextOverflow?
final
postDataText String?
Text to display after the main data
final
postDataTextStyle TextStyle?
Style for post-data text
final
preDataText String?
Text to display before the main data
final
preDataTextStyle TextStyle?
Style for pre-data text
final
richData TextSpan?
Rich text data to display
final
richPostData TextSpan?
Rich version of postDataText
final
richPreData TextSpan?
Rich version of preDataText
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectionColor Color?
final
semanticsLabel String?
final
softWrap bool?
final
strutStyle StrutStyle?
final
style TextStyle?
final
textAlign TextAlign?
final
textDirection TextDirection?
final
textHeightBehavior TextHeightBehavior?
final
textScaler TextScaler?
final
textWidthBasis TextWidthBasis?
final
trimCollapsedText String
Text to show when collapsed (e.g., "read more")
final
trimExpandedText String
Text to show when expanded (e.g., "show less")
final
trimLength int
Maximum character length when using TrimMode.length
final
trimLines int
Maximum number of lines when using TrimMode.line
final
trimMode TrimMode
Determines how text should be trimmed
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<FitReadMore>
Creates the mutable state for this widget at a given location in the tree.
override
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, int wrapWidth = 65}) 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