see_more 2.0.0
see_more: ^2.0.0 copied to clipboard
Expandable text widget with See More/Less, character/line/word trimming, programmatic SeeMoreController, custom button builders, fade effect, and smooth animations.
2.0.0 #
Breaking Changes #
TrimModeenum now has three values:character,line, andword. Any exhaustiveswitchonTrimModein consumer code must add awordcase.
New Features #
SeeMoreController— programmatic expand/collapse from outside the widget. Supportsexpand(),collapse(), andtoggle(). Keeps the widget in sync with tap-based interactions and firesonExpand/onCollapsecallbacks.final ctrl = SeeMoreController(); SeeMoreWidget("...", controller: ctrl) ctrl.expand();TrimMode.word— trim by word count instead of characters or lines. Controlled by the newmaxWordsparameter (default50).SeeMoreWidget("...", trimMode: TrimMode.word, maxWords: 30)expandButtonBuilder— replace the default "See More" span with any widget. The builder receives(BuildContext context, VoidCallback onTap).collapseButtonBuilder— same for the "See Less" affordance. Can be set independently ofexpandButtonBuilder.
Improvements #
- Line-mode TextPainter result is now cached on a
_LineTrimKeyrecord. Repeated builds that don't change text, style, or constraints skip the layout pass entirely. fadeColordefault changed fromscaffoldBackgroundColortocolorScheme.surface, matching the visible container background in Cards, Dialogs, and other surfaces.- Inline "See More" / "See Less"
TextSpans now carrysemanticsLabelso screen readers announce the label without the leading visual-spacing space. - Default expand button (fade mode) is now wrapped in
Semantics(button: true)so assistive technologies identify it as an interactive control. expandButtonSpacingis now validated to be>= 0.- Regex patterns used in trim helpers are compiled once as
static finalconstants instead of on every call. - Source split into focused
partfiles:see_more_state.dart,see_more_builders.dart,see_more_constants.dart. - Tests reorganised into focused files under
test/(74 tests total).
1.0.0 #
Breaking Changes #
- Complete rewrite with new API
- Renamed parameters for clarity:
trimLength→maxCharacterstrimLines→maxLinesseeMoreText→expandTextseeLessText→collapseTextseeMoreStyle→expandTextStyleseeLessStyle→collapseTextStyleenableFade→showFadeEffectfadeLength→fadeHeightseeMoreButtonSpacing→expandButtonSpacing
New Features #
- Fade effect - Gradient fade at text end like Instagram/Twitter (
showFadeEffect: true) - Line-based trimming - Trim by number of lines using
trimMode: TrimMode.line - Word boundary trimming - No more cutting words in half (
trimAtWordBoundary: true) - Ellipsis support - Customizable ellipsis before expand button (
ellipsis: "...") - Callbacks -
onExpandandonCollapsecallbacks for state tracking - Initial state -
initiallyExpandedparameter - Theme integration - Uses theme colors when no style provided
- Text alignment -
textAlignparameter - RTL support -
textDirectionparameter (usesDirectionality.of(context)) - Animation curve -
animationCurveparameter - Accessibility - Semantics wrapper and
textScalerparameter for font scaling - Button spacing -
expandButtonSpacingparameter for fade mode
Bug Fixes #
- Fixed memory leak - TapGestureRecognizer now properly disposed
- Fixed memory leak - TextPainter now properly disposed
- Fixed text cutting mid-word
Other #
- 25 comprehensive unit tests
- Code organized with
part/part offor better maintainability - Requires Flutter
>=3.16.0
0.0.5 #
- added video
0.0.4 #
- minor bug fixes with more attribute
0.0.3 #
- minor bug fixes
0.0.2 #
- Readme updated.
0.0.1 #
- Initial release.