搜尋套件、儲存庫與 APP 分類

套件詳情v1.2.1

rich_input

富文本輸入框,實現 @someone 和主題的顏色強調。

近 30 天下載
23
喜歡數
18
Pub 分數
40

安裝套件

flutter pub add rich_input

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

RichInput 是一個 Flutter 套件,可實現增強型文字輸入,具備豐富的格式化功能,例如 @提及和帶顏色強調的主題標籤。它支援對格式化文字的即時視覺反饋,非常適合聊天介面、評論區塊或協作編輯工具。此套件著重於自訂,讓開發者能定義模式與樣式規則,以動態呈現內容。該套件可無縫整合至現有的表單與文字欄位中,透過直觀且互動式的輸入功能提升使用者體驗。

適用情境

  • 聊天應用
  • 評論系統
  • 協作文件編輯
  • 社群媒體平台
  • 任務管理工具

主要特色

  • @mention 檢測
  • 使用顏色進行主題標記
  • 即時格式化
  • 可自訂樣式
  • 基於模式的文本強調

適合對象

  • 開發互動式文字輸入的開發者
  • 需要提及功能的應用程式
  • 具有豐富文字註釋的 UI
  • 需要協作文字功能的團隊
  • 具有動態內容標記的專案

使用建議

  • 有限的平台支援(未指定平台)
  • 需要手動設定模式
  • 可能需要額外的樣式調整
  • 依賴外部來源程式碼以取得更新
  • 未針對大規模文字處理進行優化

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

rich_input

This is a high performance rich media input box, implemented through the native textfield extension, with less disruptive, but at the same time has a strong extensibility, implements the @ someone, # topics, expressions and other functions, support custom color highlighting

Language: English | 中文简体

Special feature

  • Use native textfield capabilities with less code, less disruption and subsequent compatibility
  • Support @someone #topic and insert emojis, etc
  • Support for custom highlighting, and custom styles
  • Support for using the backspace key to delete entire special text blocks
  • Support for special character handling
  • Support for custom data fields to enhance rich text

Demo

Getting Started

Core code

import 'package:rich_input/rich_input.dart';

RichInputController controller = RichInputController(text: "Text");

const block = RichBlock(
  text: "@somebody",
  data: "@123456",
  style: TextStyle(color: Colors.blue),
);
controller.insertBlock(block);

// Get custom data
print(controller.data);
// Get text
print(controller.text);

// RichInput(controller: controller);

Example

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  RichInputController _controller;
  FocusNode _focusNode;

  @override
  void initState() {
    _focusNode = FocusNode();
    _controller = RichInputController(text: "Text");

    // Refresh text display, not required
    _controller.addListener(() {
      setState(() {});
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Padding(
          padding: const EdgeInsets.all(15),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              RichInput(
                focusNode: _focusNode,
                controller: _controller,
              ),
              Wrap(
                spacing: 10,
                children: [
                  RaisedButton(
                    onPressed: () {
                      _controller.insertText("Text");
                    },
                    child: const Text("Add Text"),
                  ),
                  RaisedButton(
                    onPressed: () {
                      _controller.insertText("😁");
                    },
                    child: const Text("Add 😁"),
                  ),
                  RaisedButton(
                    onPressed: () {
                      _controller.insertText("👍");
                    },
                    child: const Text("Add 👍"),
                  ),
                  RaisedButton(
                    onPressed: () {
                      const block = RichBlock(
                        text: "@abc",
                        data: "@123456",
                        style: TextStyle(
                          color: Colors.blue,
                          fontWeight: FontWeight.bold,
                        ),
                      );
                      _controller.insertBlock(block);
                    },
                    child: const Text("Add @    "),
                  ),
                  RaisedButton(
                    onPressed: () {
                      const block = RichBlock(
                        text: "#subject",
                        data: "#888999",
                        style: TextStyle(
                          color: Colors.red,
                          fontWeight: FontWeight.bold,
                        ),
                      );
                      _controller.insertBlock(block);
                    },
                    child: const Text("Add #"),
                  ),
                  RaisedButton(
                    onPressed: () {
                      _focusNode.unfocus();
                    },
                    child: const Text("unfocus"),
                  )
                ],
              ),
              const SizedBox(height: 10),
              Text("Text:${_controller.text}"),
              const SizedBox(height: 10),
              Text("Data:${_controller.data}"),
            ],
          ),
        ),
      ),
    );
  }
}

For detailed examples

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。