textf 1.1.0
textf: ^1.1.0 copied to clipboard
Markdown-like text styling for inline text — fully compatible with Flutter’s `Text` widget. Easily replace Text with Textf to add simple formatting.
Changelog #
All notable changes to the textf package will be documented in this file.
1.1.0 #
Breaking Changes #
- Style Inheritance Refactor: Refactored
TextfOptionsandDefaultStylesto correctly merge styles down the widget tree by passing thebaseStylethrough the resolution chain. This ensures that properties likefontSizeordecorationare correctly inherited and merged, fixing issues where child styles might blindly override parent styles or miss context.
Added #
- Named Widget Placeholders: You can now insert arbitrary Flutter widgets (via
InlineSpan) into formatted text using{key}syntax and theplaceholdersmap. (based on PR #5, thanks @admin-kinora)
Improved #
- Smart Caching System: Implemented a robust internal caching layer within the renderer.
Textfnow retains previously parsedInlineSpantrees across widget rebuilds, preventing expensive re-parsing when the text content hasn't changed. - Performance Optimization: The widget now intelligently detects changes in
TextfOptions,ThemeData, andTextScaler. It re-uses cached results even when parent widgets rebuild, provided the actual formatting configuration remains logically equivalent. This drastically reduces CPU overhead during animations and list scrolling. - Internal Optimization: Refactored
TextfParserto useStringBufferfor text accumulation, improving performance for large text blocks.
1.0.0 #
BREAKING CHANGES #
- API Renaming: Renamed all
TextfOptionsproperties and callbacks related to links to use the termlinkinstead ofurlfor better consistency with Markdown terminology and improved API clarity. For example,urlStyleis nowlinkStyleandonUrlTapis nowonLinkTap.
Added #
- Superscript & Subscript: Added support for
^superscript^and~subscript~formatting. - Accessibility Enhancements: Improved link semantics in
HoverableLinkSpanfor better screen reader support.
Changed #
- URL Normalization: Updated the default fallback for scheme-less URLs (e.g., google.com) to prepend https:// instead of http:// .
- Internal Refactoring: Major refactoring of the
TextfTokenizerfor improved maintainability and performance. - RTL Support: Verified and enhanced Right-to-Left (RTL) support throughout the widget and its components.
- Performance: Refactored the internal parsing loop to improve performance and reduce memory allocation, especially with complex formatted text.
- Optimization: Minor optimizations to internal link rendering logic and widget instantiation for better efficiency.
Fixed #
- Link Handling: Fixed an issue in the URL normalization logic that would incorrectly prepend
http://to non-HTTP schemes likemailto:ortel:. - Styling: Corrected an issue where nested
TextfOptionscould improperly combineTextDecorationstyles, potentially leading to visual duplication. The style merging logic is now more robust.
0.6.1 #
Changed #
- Formatted codebase for consistency and readability
- Updated documentation for clarity and completeness
0.6.0 #
BREAKING CHANGES #
- Style Inheritance Logic: The logic for inheriting
TextStyleproperties from nestedTextfOptionshas been completely refactored to be more intuitive and powerful.- Previous Behavior: A
TextStyleproperty (likeboldStyle) in a childTextfOptionswould completely overwrite the style from a parent. For example, a child'sdecorationwould replace the parent'sdecoration. - New Behavior:
TextStyleproperties are now merged down the tree. Decorations from parent and childTextfOptionsare intelligently combined, allowing for layering (e.g., adding a strikethrough to text that is already underlined by a parent).
- Previous Behavior: A
Fixed #
- TextfOptions does not combine decorations from nested widgets (#3)
0.5.0 #
Breaking Changes #
-
Hover Callbacks: Changed hover callback parameters from positional to named parameters for improved API clarity. The
onUrlHovercallback now usesisHoveringas a named parameter:// Before: onUrlHover: (url, displayText, true) // After: onUrlHover: (url, displayText, isHovering: true)
Added #
- Enhanced Code Analysis: Integrated
very_good_analysisanddart_code_metricsfor improved code quality and consistency - Unit Tests: Added comprehensive unit tests for
NestingValidatorclass
0.4.0 #
2025-05-18
Added #
-
Underline Formatting: Implemented support for underline formatting with
++text++syntax. -
Highlight Formatting: Implemented support for highlight formatting with
==text==syntax. -
Improved Decoration Handling: Default styles for strikethrough and underline now attempt to combine with existing decorations on the base style, allowing for concurrent
++~~underline and strikethrough~~++.decorationColoranddecorationThicknessfrom the most recently applied default decoration orTextfOptionswill take precedence for the combined decoration.
Changed #
- TextfOptions: Extended with
underlineStyleandhighlightStyleproperties. - Link Formatting:
- Nested text decorations within link display text (e.g.,
[~~strikethrough~~](url)) are now correctly combined with the link's own decoration (e.g., underline), ensuring both are visually applied. - Improved application of
TextfOptions.urlHoverStyle, ensuring hover-specific styles correctly merge with the link's resolved normal appearance, preserving properties like color and font size unless explicitly overridden by the hover style.
- Nested text decorations within link display text (e.g.,
- Internal Refactoring: Enhanced
TokenTypeenum to directly indicate if a token is for links or formatting. This improves internal parsing logic inPairingResolverandTextfParserfor minor performance gains and better code clarity. (Thanks @timmaffett!)
0.3.0 #
2025-04-18
Added #
- Theme-Aware Default Styling: Implemented theme-aware default styling for inline code (
`code`) and links ([text](url)). Their appearance now automatically adapts to the application'sThemeData(e.g., usingcolorScheme.primaryfor links, theme-appropriate background/text for code) unless overridden byTextfOptions. strikethroughThicknessOption: Added thestrikethroughThicknessproperty toTextfOptionsto allow customizing the line thickness for~~strikethrough~~text when not providing a fullstrikethroughStyle.TextScalerSupport: Added support for thetextScalerproperty, allowingTextfto respect system font scaling settings and customTextScalerinstances, similar to the standardTextwidget.
Changed #
- Documentation: Significantly enhanced
README.mdwith detailed explanations of allTextfOptionsproperties, their inheritance behavior, and added styling recommendations. - Code Font Defaults: Improved default font family fallbacks for inline code (
code) for better cross-platform rendering when a specificcodeStyleis not provided (usesRobotoMono,Menlo,Courier New,monospace).
Removed #
- Internal Caching: Removed the internal caching mechanism for parsed results to simplify the parsing logic and resolve potential inconsistencies during hot reload. Performance remains optimized through efficient algorithms.
Fixed #
- Internal: Updated internal tests to correctly account for the new theme-aware default styles.
0.2.1 #
2025-04-12
Fixed #
- Hot Reload Reliability: Fixed an issue where changes made to
TextfOptions(e.g., custom colors, styles) or internal formatting logic might not render correctly immediately after using hot reload during development. The internal parser cache is now properly invalidated only in debug mode duringreassemble, ensuring UI consistency and improving the development workflow without affecting release build performance.
0.2.0 #
2025-04-12
Added #
-
Link Support: Implemented full support for Markdown-style links with
[text](url)syntax- Added interactive link styling with customizable colors and decorations
- Created hover effects for links with mouse cursor changes
- Enabled nested formatting within link text (e.g.,
[**bold** link](url)) - Added
onUrlTapandonUrlHovercallbacks for link interaction
-
TextfOptions: Introduced a new widget to customize text formatting styles
- Global styling options for all formatting types (bold, italic, code, etc.)
- Configurable link appearance and behavior
- Inheritance-based configuration through the widget tree
-
Enhanced Styling: Added support for more detailed text styling
- Font family customization for code blocks
- Expanded default styles for each formatting type
Fixed #
- Updated default font family for inline code text to RobotoMono for better readability
- Enabled trailing commas in analysis options for code consistency
0.1.1 #
0.1.0 #
2025-04-04
Added #
- Initial release of Textf lightweight text formatting widget
- Support for bold formatting with
**text**or__text__ - Support for italic formatting with
*text*or_text_ - Support for combined bold+italic with
***text***or___text___ - Support for strikethrough with
~~text~~ - Support for inline code with
`code` - Escape character support with backslash
- Performance optimization with caching
- Nested formatting support (up to 2 levels deep)
0.0.1 #
- Initial release of Textf widget.
