text_highlight_codespark 1.0.0 copy "text_highlight_codespark: ^1.0.0" to clipboard
text_highlight_codespark: ^1.0.0 copied to clipboard

A Flutter package for highlighting text within a string, supporting single, multiple, and regex-based queries.

example/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
            title: const Text('HighlightText Example')), // App bar with title
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Center(
                child: HighlightText(
                  query: "example", // Single query to highlight
                  source:
                      'This is an example of text highlighting.', // Source text to search within
                  caseSensitive: false, // Case insensitivity option
                  highlightColor: Colors.yellow.shade700, // Highlight color
                ),
              ),
              const SizedBox(height: 24), // Spacer between examples
              Center(
                child: HighlightText.multiple(
                  queires: const [
                    'highlight',
                    'text',
                    'example',
                    'multiple'
                  ], // Multiple queries to highlight
                  source:
                      'This is an example of highlighting multiple queries in the text.', // Source text to search within
                  caseSensitive: false, // Case insensitivity option
                  highlightColor: Colors.yellow.shade700, // Highlight color
                ),
              ),
              const SizedBox(height: 24), // Spacer between examples
              Center(
                child: HighlightText.regex(
                  regex:
                      r'\b\d{4}\b', // Regular expression pattern to highlight four-digit numbers
                  source:
                      'The years 2023, 2024, and 2025 are important.', // Source text to search within
                  caseSensitive: false, // Case insensitivity option
                  highlightColor: Colors.yellow.shade700, // Highlight color
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
12
likes
140
pub points
58%
popularity
screenshot

Publisher

verified publisherksaikiran.site

A Flutter package for highlighting text within a string, supporting single, multiple, and regex-based queries.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on text_highlight_codespark