パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v3.0.1

rich_text_controller

カスタム正規表現パターン用に異なるインラインスタイルをサポートする拡張テキスト編集コントローラー。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
7920
いいね数
104
Pub ポイント
160

パッケージをインストール

flutter pub add rich_text_controller

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

rich_text_controller は、カスタム正規表現に基づいてテキストにインラインスタイルを適用できるように拡張された、Flutter/Dart パッケージです。ハッシュタグ、メンション、リンクなどの特定のパターンに対して、色、フォント、装飾など異なるスタイルを適用できます。メッセージアプリ、ノートツール、ソーシャルメディアインターフェースにおけるリッチテキスト入力に最適で、構造化されたコンテンツを視覚的に区別することでユーザー体験を向上させます。このパッケージはすべての主要プラットフォームをサポートしており、既存の TextEditingController ワークフローとシームレスに統合可能です。

用途

  • スタイリッシュなメンション付きのメッセージアプリ
  • 構文強調付きノートアプリ
  • ハッシュタグスタイルを備えたソーシャルメディア用テキストフィールド
  • カスタムリッチテキストエディタ
  • リアルタイム共同編集

主な機能

  • 正規表現パターンによるインラインスタイル
  • 複数のスタイルタイプをサポート
  • TextEditingController とのシームレスな統合
  • クロスプラットフォーム互換性
  • スタイリッシュテキストのライブプレビュー
  • 設定可能なパターンマッチング

適している対象

  • 豊富なテキスト入力フィールドを構築する開発者
  • 動的テキストフォーマットが必要なアプリ
  • ユーザー生成コンテンツを含むプロジェクト
  • 正規表現ベースのコンテンツタグを使用するチーム
  • テキストパターンの視覚的区別が必要な UI

注意事項

  • パフォーマンスの問題を避けるために、正規表現の設計に注意が必要です
  • 複雑なパターンを使用するとメモリ使用量が増加する可能性があります
  • スタイリングロジックは、複数のプラットフォームでテストされるべきです
  • 大規模な文書編集には適していません
  • 一般的な用途に適した限定的な組み込みテンプレート

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

rich_text_controller

Pub Version License Pub Points

rich_text_controller is an extended text editing controller for Flutter that supports applying different inline styles based on custom regex patterns. This package simplifies text styling and interaction in Flutter applications, making it easy to create feature-rich text inputs.


Table of Contents

  1. Demo
  2. Features
  3. Installation
  4. Usage
  5. Contributing
  6. License

Demo

Demo GIF

Features

  • Custom Regex Styling: Apply styles dynamically to text patterns.
  • Interactive Callbacks: Define actions for user interactions with matched text.
  • Dynamic Updates: Modify regex patterns on the fly without recreating the controller.
  • IME Composition Support: Smooth handling for languages like Japanese and Chinese.
  • Performance Optimizations: Cached regex for better performance.
  • RichWrapper Widget: A widget for seamless integration with the controller.
  • Fine-grained Configuration: Control deletion behavior, styles, and tap actions for specific matches.

Installation

  1. Add the package to your pubspec.yaml file:
dependencies:
  rich_text_controller: ^[latest_version]
  1. Run the following command to install the package:
flutter pub get
  1. Import the package into your Dart file:
import 'package:rich_text_controller/rich_text_controller.dart';

Usage

Here's a quick example of how to use RichTextController to style specific patterns in a TextField:

Example
import 'package:flutter/material.dart';
import 'package:rich_text_controller/rich_text_controller.dart';

defaultTextStyle(BuildContext context) => TextStyle(color: Colors.black);

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('RichTextController Example')),
        body: Center(
          child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: TextField(
              controller: RichTextController(
                text: '',
                onMatch: (match, target) {
                  print('Match found: \$match');
                },
                targetMatches: [
                  MatchTargetItem(
                    textStyle: TextStyle(color: Colors.blue, fontWeight: FontWeight.bold),
                    regex: RegExp(r'#[a-zA-Z0-9_]+'),
                  ),
                  MatchTargetItem(
                    textStyle: TextStyle(color: Colors.green),
                    regex: RegExp(r'@[a-zA-Z0-9_]+'),
                  ),
                ],
              ),
              decoration: InputDecoration(border: OutlineInputBorder()),
            ),
          ),
        ),
      ),
    );
  }
}

Contributing

Contributions are always welcome! Here’s how you can help:

  1. Report bugs or request features via GitHub Issues.
  2. Submit pull requests with well-documented code and examples.
  3. Share your thoughts and ideas to improve the package.

License

Licensed under the MIT License. You are free to use, modify, and distribute this package. See the LICENSE.md file for details.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト