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

detectable_text_field のカバー
パッケージ詳細v3.0.2

detectable_text_field

検出機能付きのTextField。ハッシュタグ、アットマーク、URL、または任意のものを検出できます。Twitterのようなアプリを開発するのに役立ちます。hashtagableの改善版。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
3540
いいね数
165
Pub ポイント
130

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

flutter pub add detectable_text_field

パッケージ概要

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

リアルタイムでハッシュタグ、@メンション、URL、カスタム正規表現パターンを検出しハイライトするFlutterテキストフィールドです。Twitterのようなソーシャルメディアアプリの構築に最適化されており、インタラクティブなテキスト解析によりユーザー入力を強化します。このパッケージは、先行製品であるhashtagableの機能をさらに洗練し、より高い柔軟性とカスタマイズ性を提供しています。Android、iOS、Web、macOS、Windows、Linuxなど複数のプラットフォームに対応しており、クロスプラットフォームのリッチテキストアプリ開発に最適です。

用途

  • ソーシャルメディアアプリ開発
  • リアルタイムテキストパターン検出
  • Twitter風の入力フィールド
  • カスタムテキストのハイライト
  • メッセージアプリにおけるリッチテキスト編集
  • インタラクティブな URL およびタグ認識

主な機能

  • カスタム正規表現パターンの検出をサポート
  • リアルタイムテキスト解析
  • カスタマイズ可能なハイライトスタイル
  • クロスプラットフォーム互換性
  • 既存の TextField との簡単な統合
  • 追加のパターンタイプに対応可能

適している対象

  • ソーシャルネットワークアプリを開発する開発者
  • 動的テキストフォーマットが必要なアプリ
  • 豊富なテキスト入力コンポーネントを作成するチーム
  • 複数プラットフォーム向けのFlutter開発者
  • 高度なテキストフィールドの挙動を望むユーザー

注意事項

  • カスタムパターン用に正規表現を慎重に設定する必要があります
  • 複雑なパターンではパフォーマンスに影響する可能性があります
  • 基本的な使用方法以外のドキュメントは限られている
  • 非常に長いテキスト入力には最適化されていません
  • 更新のために外部のGitHubリポジトリに依存しています

元の README

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

detectable_text_field

All Contributors

pub package License: MIT

Text widgets with detection features. You can detect hashtags, at sign, url, or anything you want. Helps you develop Twitter like app.

Refinement of hashtagable.

final

Usage

DetectableTextField
    DetectableTextField(
      detectionRegExp: detectionRegExp(),
      detectedStyle: TextStyle(
        fontSize: 20,
        color: Colors.blue,
      ),
    )
  • detectionRegExp decides the text to detect.
  • detectedStyle is the textStyle for detected text.
DetectableTextEditingController

DetectableTextEditingController allows you to listen to the typingDetection. Ideal for features like live hashtag or mention detection.


    final controller = DetectableTextEditingController(
      regExp: detectionRegExp(),
    );
    
    @override
    void initState() {
      super.initState();
      controller.addListener(() {
        setState(() {});
      });
    }
    
    @override
    Widget build(BuildContext context) {
      return Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text(
            'Typing detection: ${controller.typingDetection}',
          ),
          DetectableTextField(
            controller: controller,
          ),
        ],
      );
    }

DetectableTextEditingController extends TextEditingController, so you can use it with TextField, TextFormField or any other widgets that accept TextEditingController.

If you use flutter_hooks, useDetectableTextEditingController is also available.

DetectableText

If you want to use detection feature in the text only to display, use DetectableText.

    DetectableText(
      text: "#HashTag and @AtSign and https://pub.dev/packages/detectable_text_field",
      detectionRegExp: detectionRegExp(),
      detectedStyle: TextStyle(
        fontSize: 20,
        color: Colors.blue,
      ),
      basicStyle: TextStyle(
        fontSize: 20,
      ),
      onTap: (tappedText){
        print(tappedText);
      },
    )

Usage of the arguments like detectionRegExp are same as the ones in DetectableTextField.

The argument onTap(String) is called when user tapped a detected text.

detectionRegExp()

The widgets and methods in this package is expected to be used with RegExp.

The function detectionRegExp() returns sample regExp depending on the boolean arguments: hashtag , atSign, and url.They are all true by default.

If you see the API reference , you will see the function just returns the sample regular expressions below. You can use them directly if you want.

sample regExp hashtag atSign url
hashTagRegExp ○ × ×
atSignRegExp × ○ ×
urlRegExp × × ○
hashTagAtSignRegExp ○ ○ ×
hashTagUrlRegExp ○ × ○
AtSignUrlRegExp × ○ ○
hashTagAtSignUrlRegExp ○ ○ ○
  • The detection rules are almost same as X(formally twitter).
    1. It needs space before # or @.
    2. It stops # and @ detection if there's emoji or symbol.
  • The examples currently support six languages: English, Japanese, Korean, Spanish, Arabic, and Thai.
Customize with useful functions
  • Check if there are detections
  print(isDetected("Hello #World", hashTagRegExp));
// true

  print(isDetected("Hello World", hashTagRegExp));
// false

  • Extract detections from text

  final List<String> detections = extractDetections(
    "#Hello World #Flutter Dart #Thank you", 
    hashTagRegExp,
  );
  // ["#Hello", "#Flutter", "#Thank"]

If you have any requests or questions, please feel free to ask on github.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Santa Takahashi
Santa Takahashi

💻
Paresh Patil
Paresh Patil

💻
Joseph Muller
Joseph Muller

💻
Esteve Aguilera
Esteve Aguilera

💻
MATTYGILO
MATTYGILO

💻
Abdullahi A. Addow
Abdullahi A. Addow

💻
Social Jawn
Social Jawn

💻
xuxiaowei13
xuxiaowei13

💻
debuggerx01
debuggerx01

💻
furukaze-akane
furukaze-akane

💻
drown0315
drown0315

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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

データはまだありません。