rich_text_controller
사용자 정의 정규 표현식 패턴에 대해 다양한 인라인 스타일을 지원하는 확장된 텍스트 편집 컨트롤러입니다.
사용자 정의 정규 표현식에 대해 다양한 인라인 스타일을 지원하는 확장된 텍스트 편집 컨트롤러
{"sdk":"flutter"}{"sdk":"flutter"}^5.0.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
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.
pubspec.yaml file:dependencies:
rich_text_controller: ^[latest_version]
flutter pub get
import 'package:rich_text_controller/rich_text_controller.dart';
Here's a quick example of how to use RichTextController to style specific patterns in a TextField:
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()),
),
),
),
),
);
}
}
Contributions are always welcome! Here’s how you can help:
Licensed under the MIT License. You are free to use, modify, and distribute this package. See the LICENSE.md file for details.