{"id":32271017,"url":"https://github.com/interdev7/flutter_text_sniffer","last_synced_at":"2026-02-21T07:02:33.227Z","repository":{"id":257820813,"uuid":"870836898","full_name":"interdev7/flutter_text_sniffer","owner":"interdev7","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-11T19:47:02.000Z","size":139,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-11T20:32:46.734Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/interdev7.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-10T18:54:37.000Z","updated_at":"2024-12-11T19:47:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"f986f941-8478-4659-817c-32ab5fee597a","html_url":"https://github.com/interdev7/flutter_text_sniffer","commit_stats":null,"previous_names":["interdev7/flutter_text_sniffer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/interdev7/flutter_text_sniffer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interdev7%2Fflutter_text_sniffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interdev7%2Fflutter_text_sniffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interdev7%2Fflutter_text_sniffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interdev7%2Fflutter_text_sniffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/interdev7","download_url":"https://codeload.github.com/interdev7/flutter_text_sniffer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/interdev7%2Fflutter_text_sniffer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29675917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T06:23:40.028Z","status":"ssl_error","status_checked_at":"2026-02-21T06:23:39.222Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-22T22:45:09.330Z","updated_at":"2026-02-21T07:02:33.211Z","avatar_url":"https://github.com/interdev7.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TextSniffer\n\n![text_sniffer](https://github.com/user-attachments/assets/f9a6264e-863a-486f-91e4-fa9d2292f0a9)\n\n`TextSniffer` is a powerful Flutter widget designed to detect and interact with specific text patterns. It allows developers to define custom patterns using regular expressions, apply unique styles to detected text, and handle user interactions such as taps on links or specific words.\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Custom Builder](#custom-builder)\n- [Defining Custom sniffers](#defining-custom-patterns)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- **Customizable Patterns**: Use regular expressions to define text patterns.\n- **Interactive Text**: Make text segments interactive, responding to user taps.\n- **Styling Options**: Apply styles to both matching and non-matching text.\n- **Custom Match Builders**: Define how detected patterns appear.\n- **Multiple Search Sniffers**: Supports for emails and links by default but you can create own Sniffers.\n- **Individual Styling**: Style different types of matches individually.\n\n## Installation\n\nTo use `TextSniffer`, add the following to your `pubspec.yaml`:\n\n```dart\ndependencies:\n  flutter_text_sniffer: ^latest_version\n```\n\nThen, run `flutter pub get` to install the package.\n\n## Usage\n\n### Basic Example\n\nHere’s a simple example of how to use the `TextSniffer` widget:\n\n```dart\nTextSniffer(\n   text: \"Contact us at support@example.com or visit https://example.com/product?name=iPhone\",\n   snifferTypes: [\n    // They are built in sniffers\n     EmailSnifferType(), \n     LinkSnifferType(),\n   ],\n   onTapMatch: (match, matchText, type, index, error) {\n     if (error == null) {\n       print('Tapped on: $matchText');\n     }\n   },\n)\n```\n\n\u003cimg width=\"200\" alt=\"image\" src=\"https://github.com/user-attachments/assets/c9c6f7b1-069f-4a8c-80a1-ad65735957ef\"\u003e\n\n## Custom Builder\n\nTo customize how matched text is displayed, use the `matchBuilder` property:\n\n```dart\nfinal images = \u003cString\u003e[\n  \"assets/flutter.png\",\n  \"assets/google.png\",\n];\n\nclass CustomSnifferType extends SnifferType {\n  @override\n  RegExp get pattern =\u003e RegExp(r'\\[(.*?)\\]');\n\n  @override\n  TextStyle? get style =\u003e const TextStyle(color: Colors.indigoAccent, fontWeight: FontWeight.bold);\n\n  @override\n  String toString() =\u003e 'custom';\n}\n\nTextSniffer\u003cString\u003e(\n  text: \"Check out [Flutter] and [Google]!\",\n  matchEntries: const ['https://flutter.dev', 'https://google.com'],\n  snifferTypes: [\n    CustomSnifferType(),\n  ],\n  onTapMatch: (entry, match, type, index, error) {\n    if (error == null) {\n      showSnackBar(context, entry ?? \"Not found\");\n    }\n  },\n  matchBuilder: (match, index, type, entry) {\n    return Container(\n      padding: const EdgeInsets.only(left: 4.0, right: 4.0),\n      child: Row(\n        mainAxisSize: MainAxisSize.min,\n        children: [\n          Image.asset(\n            images[index],\n            width: 20,\n            height: 20,\n          ),\n          Text(\n            match,\n            style: type.style,\n          ),\n        ],\n      ),\n    );\n  },\n)\n```\n\n\u003cimg width=\"200\" alt=\"image\" src=\"https://github.com/user-attachments/assets/2492ed6c-7c50-4617-96f6-0926ccb077dc\"\u003e\n\n## Defining Custom Patterns\n\nYou can define custom patterns using regular expressions. For example, to detect IP addresses, hashtag and custom:\n\n```dart\n// Custom sniffer. For example: [Example] =\u003e word in brackets =\u003e Example\nclass CustomSnifferType extends SnifferType {\n  @override\n  RegExp get pattern =\u003e RegExp(r'\\[(.*?)\\]');\n\n  @override\n  TextStyle? get style =\u003e const TextStyle(color: Colors.indigoAccent, fontWeight: FontWeight.bold);\n\n  @override\n  String toString() =\u003e 'custom';\n}\n\n// IP address sniffer\nclass IpAddressSnifferType extends SnifferType {\n  @override\n  RegExp get pattern =\u003e RegExp(r'\\b' // Start of word (word borders)\n      r'(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' // 1 octet\n      r'\\.' // Dot\n      r'(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' // 2 octet\n      r'\\.' // Dot\n      r'(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' // 3 octet\n      r'\\.' // Dot\n      r'(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' // 4 octet\n      r'\\b' // End of word\n      );\n\n  @override\n  TextStyle? get style =\u003e const TextStyle(color: Colors.orange, fontStyle: FontStyle.italic);\n\n  @override\n  String toString() =\u003e 'ip_address';\n}\n\n// Hashtag sniffer\nclass HashtagSnifferType extends SnifferType {\n  @override\n  RegExp get pattern =\u003e RegExp(r'\\B#\\w\\w+');\n\n  @override\n  TextStyle? get style =\u003e const TextStyle(color: Colors.purple, fontWeight: FontWeight.bold);\n\n  @override\n  String toString() =\u003e 'hashtag';\n}\n\nTextSniffer(\n  text: \"Check out [Flutter] and [Google]!\\nCheck out #Flutter and #Google! IP addresses: 192.168.0.1, 192.168.0.124\",\n  snifferTypes: [\n    CustomSnifferType(),\n    HashtagSnifferType(),\n    IpAddressSnifferType(),\n  ],\n  matchEntries: const [\n    'https://flutter.dev',\n    'https://google.com',\n  ],\n  onTapMatch: (entry, matchText, type, index, error) {\n    if (error == null) {\n      print('Tapped on: $matchText');\n    }\n  },\n)\n```\n\n\u003cimg width=\"200\" alt=\"image\" src=\"https://github.com/user-attachments/assets/d5a97bff-a10e-4098-aeca-ad8e5d438c1a\"\u003e\n\n## Contributing\n\nWe welcome contributions! To contribute to `TextSniffer`, please follow these steps:\n\n1. Fork the repository.\n2. Create a new branch (`git checkout -b feature/AmazingFeature`).\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).\n4. Push to the branch (`git push origin feature/AmazingFeature`).\n5. Open a Pull Request.\n\n## License\n\nThis project is licensed under the BSD-3-Clause License. See the [LICENSE](LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterdev7%2Fflutter_text_sniffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finterdev7%2Fflutter_text_sniffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finterdev7%2Fflutter_text_sniffer/lists"}