rich_highlight_text_codespark 0.0.2 copy "rich_highlight_text_codespark: ^0.0.2" to clipboard
rich_highlight_text_codespark: ^0.0.2 copied to clipboard

Adds extension methods to highlight substrings in Text or String using Text.rich and custom styles. Simple inline highlighting with minimal code.

Banner

✨ rich_highlight_text_codespark #

Pub Version
GitHub

Highlight specific substrings within your Flutter Text widgets effortlessly. Whether it's a single word or multiple phrases, rich_highlight_text_codespark provides a seamless way to emphasize parts of your text with customizable styles.

🎯 Fully null-safe and optimized for performance.

πŸš€ Features #

  • βœ… Highlight single or multiple substrings
  • βœ… Support for case-sensitive and case-insensitive matching
  • βœ… Highlight modes: first occurrence, last occurrence, or all occurrences
  • βœ… Handles overlapping and adjacent matches gracefully
  • βœ… Customizable highlight styles
  • βœ… Seamless integration with existing Text widgets

πŸ“¦ Installation #

Add the following to your pubspec.yaml:

dependencies:
  rich_highlight_text: ^1.0.0

Then, run:

flutter pub get

πŸ§ͺ Usage #

πŸ” Highlight a Single Substring #

import 'package:flutter/material.dart';
import 'package:rich_highlight_text/rich_highlight_text.dart';

Text(
  'Welcome to Flutter!',
  style: TextStyle(fontSize: 18),
).highlight(
  'Flutter',
  highlightStyle: TextStyle(color: Colors.blue, fontWeight: FontWeight.bold),
);
'Flutter is fun and powerful!'.toRichText(
  style: TextStyle(fontSize: 18),
  highlights: ['Flutter', 'powerful'],
  highlightStyle: TextStyle(color: Colors.orange, fontWeight: FontWeight.bold),
  onTap: (text) {
    print('Tapped: $text');
  },
);
Text(
  'Flutter is fun and powerful!',
  style: TextStyle(fontSize: 18),
).highlight(
  'Flutter',
  highlightStyle: TextStyle(
    color: Colors.blue,
    fontWeight: FontWeight.bold,
    decoration: TextDecoration.underline,
  ),
  onTap: (text) {
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(content: Text('You tapped on "$text"!')),
    );
  },
);

✨ Highlight Multiple Substrings #

Text(
  'Flutter makes development faster and easier.',
  style: TextStyle(fontSize: 18),
).highlightMultiple(
  ['Flutter', 'faster', 'easier'],
  highlightStyle: TextStyle(color: Colors.green, fontWeight: FontWeight.bold),
);

🎯 Highlight Modes #

  • HighlightMode.all: Highlights all occurrences (default)
  • HighlightMode.first: Highlights only the first occurrence
  • HighlightMode.last: Highlights only the last occurrence
Text(
  'Flutter is awesome. Flutter is fast.',
  style: TextStyle(fontSize: 18),
).highlight(
  'Flutter',
  highlightStyle: TextStyle(color: Colors.red),
  highlightMode: HighlightMode.first,
);

πŸ“Έ Preview #

Highlight Example 1

πŸ› οΈ API Reference #

highlight #

Text highlight(
  String highlightText, {
  TextStyle? highlightStyle,
  bool caseSensitive = true,
  HighlightMode highlightMode = HighlightMode.all,
  // Additional Text parameters...
});

highlightMultiple #

Text highlightMultiple(
  List<String> highlightTexts, {
  TextStyle? highlightStyle,
  bool caseSensitive = true,
  HighlightMode highlightMode = HighlightMode.all,
  // Additional Text parameters...
});

πŸ“ˆ Roadmap #

  • βœ… Highlight single substring
  • βœ… Highlight multiple substrings
  • βœ… Support for different highlight modes
  • ❌ Support for regular expressions
  • ❌ Animation support for highlights
  • ❌ Integration with SelectableText

🌍 Internationalization #

βœ… Supports Unicode and multilingual characters. 🌐 Fully compatible with languages like Arabic, Chinese, Hindi, and more.

πŸ“‚ Example #

Clone the repository and navigate to the example/ directory:

git clone https://github.com/Katayath-Sai-Kiran/rich_highlight_text.git
cd rich_highlight_text/example
flutter run

πŸ™Œ Contributions #

Contributions are welcome! Please open issues and submit pull requests for any features, bugs, or enhancements.

πŸ‘¨β€πŸ’» Maintainer #

Developed with ❀️ by Katayath Sai Kiran

5
likes
150
points
124
downloads
screenshot

Publisher

verified publisherksaikiran.tech

Weekly Downloads

Adds extension methods to highlight substrings in Text or String using Text.rich and custom styles. Simple inline highlighting with minimal code.

Repository (GitHub)
View/report issues

Topics

#text #highlight #richtext #inline-style #textspan

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on rich_highlight_text_codespark