flutter_text_sniffer 8.0.0
flutter_text_sniffer: ^8.0.0 copied to clipboard
A widget that detects specific patterns within a text and makes them interactive.
8.0.0 #
- Breaking:
TextSniffernow inherits the ambientMediaQuerytext scaler by default (previouslyTextScaler.noScaling), so text respects the system font-size accessibility setting. PasstextScaler: TextScaler.noScalingto restore the old behavior. - Breaking:
LinkSniffer's default pattern is stricter — it now only matches URLs with an explicit scheme (https://…) or awww.prefix, instead of anyword.tld-looking token. UseLinkSniffer(pattern: LinkSniffer.loosePattern)for the old permissive behavior. - Added built-in
PhoneSniffer,HashtagSnifferandMentionSniffer. - Added
onLongPressMatchcallback — long-pressing a match (e.g. to copy a phone number) now works on both styled spans andmatchBuilderwidgets; a long press suppresses the subsequent tap. - Added
Sniffer.hoverStyle— a style merged into the match style while the mouse hovers over it (web/desktop). TextSniffernow registers with an enclosingSelectionAreaautomatically, making the text selectable without manualselectionRegistrarwiring; the selection color falls back to the ambientDefaultSelectionStyle.matchBuilderwidgets are now exposed to accessibility as buttons.sniffer_types.dartis now exported from the main library — a singleimport 'package:flutter_text_sniffer/flutter_text_sniffer.dart';suffices.RegexCacheis now bounded (128 entries, oldest evicted), so dynamically generated patterns can no longer grow it without limit.- Added
repository/issue_trackermetadata to the pubspec.
7.0.0 #
- Breaking: removed
errorparameter fromOnTapMatchcallback. - Added
onErrorcallback toTextSnifferto handle errors thrown duringonTapMatchexecution.
6.0.0 #
- Breaking: renamed
SnifferType→Sniffer,EmailSnifferType→EmailSniffer,LinkSnifferType→LinkSniffer. Update your custom sniffer subclasses to extendSnifferinstead ofSnifferType. - Breaking: renamed widget parameter
snifferTypes→sniffers. - Breaking: each sniffer is now matched with its own regex instead
of a single combined pattern. This preserves per-pattern flags (e.g.
caseSensitive: false) and resolves overlapping matches by sniffer priority (order in thesnifferslist). - Added
entryResolvercallback — an alternative to positionalmatchEntriesthat resolves entries by matched text/type instead of index. Robust when the text or match count changes. - Added
mouseCursor: SystemMouseCursors.clickon matched spans for web/desktop. - Example: added
book_excerpt_example.dart— an annotated book reader demonstratingentryResolverwith character names and glossary terms (Alice in Wonderland excerpt).
5.0.2 #
- Fixed: changing
snifferTypeswithout changingtextnow correctly re-parses. Previously the widget compared the old sniffer signature against itself, so pattern/type changes on an existingTextSnifferwere ignored until the text also changed. - Tests: reached 100% line coverage (added coverage for
matchBuilder,snifferTypesre-parsing,LinkSnifferType,SnifferType.toString, and the deprecatedtextScaleFactorgetter). - Chore: added CI (analyze, format, tests with enforced 100% coverage, publish-on-release) and switched the license to MIT.
5.0.1 #
- Docs: documented
onTapMatch/matchEntriesbehavior (entry is optional and per-match;indexis global across all matches;erroris reserved). - Docs: added a "Large Texts (books, articles)" guide — chunk long text with
ListView.builderinstead of one bigTextSniffer. - Example: added
long_text_example.dart(lazyListView.builderdemo) plus a toolbar button to open it; switched example logging todebugPrint. - Tests: added widget tests covering parsing, tap handling and re-parsing.
5.0.0 #
- Breaking: removed
NoMatchEntryFoundException. Tapping a match no longer throws whenmatchEntriesis empty or shorter than the number of matches —onTapMatchis now always called withmatch: nullanderror: nullin that case.matchEntriesis fully optional and per-match. - Fixed: case-insensitive matching is now preserved (regex flags were lost via the internal regex cache, breaking uppercase emails/links).
- Fixed: tap callbacks no longer reuse a wrong
indexwhen the same text is matched more than once (matched spans are no longer cached by text). - Fixed:
sniffersTypeswith anull/empty pattern no longer produce an empty regex alternative that matched every position. - Perf: matches are materialized once instead of rebuilding the list per match.
- Fixed:
TapGestureRecognizers created per match are now disposed (previously leaked on every rebuild).TextSnifferis now aStatefulWidget. - Perf: text is parsed (regex run) only when
textorsnifferschange, not on every rebuild — important for large texts. - Non-matching text now defaults to
DefaultTextStyle(theme/dark-mode aware) instead of hard-coded black.
4.4.4 #
- Added the ability to create your own sniffer types.
- Updated documentation
3.4.0 #
- Improved documentation with detailed examples for
onTapMatchand styling matches. - Enhanced README with usage instructions and examples for better developer experience.
3.3.0 #
-
New: Added support for enhanced matching logic with optional entries.
-
Added
overflowproperty -
Introduced
searchTypesto refine search for specific patterns (e.g., phone, email, link, custom). -
Optimized
onTapMatchcallback handling for better interaction with matched text.
2.2.0 #
- fixed:
maxLinesand regular expression for multiple groups
1.2.0 #
- fixed:
matchEntrynow is nullable becausematchEntriescan be empty
1.1.0 #
- Fixed
maxLines
1.0.0 #
- Created package