패키지, 저장소 및 앱 카테고리 검색

패키지 상세v3.0.1

rich_text_controller

사용자 정의 정규 표현식 패턴에 대해 다양한 인라인 스타일을 지원하는 확장된 텍스트 편집 컨트롤러입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
7.9천
좋아요
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.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트