搜尋分類、套件與程式碼儲存庫

mentionable_text_field 封面
套件詳情v0.0.2

mentionable_text_field

一個 Flutter 插件,用於建立可自訂的文字欄位,具備提及功能。符合使用者的顯示與選擇方式與元件本身分離,讓您能自由選擇實作方式。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
267
喜歡數
35
Pub 分數
130

安裝套件

flutter pub add mentionable_text_field

套件介紹

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

一個可自訂的Flutter文字欄位外掛,支援提及功能,讓使用者能在文字中標記他人。它將比對與顯示提及的邏輯與UI分離,提供彈性的方式呈現和選擇建議。適合用於聊天或社交應用,支援Android、iOS、Web、macOS、Windows及Linux等多個平台。此外掛專為希望完全掌控提及體驗,卻又不受特定UI元件束縛的開發者所設計。

適用情境

  • 聊天應用
  • 社群媒體平台
  • 協作編輯工具
  • 評論中的使用者標記
  • 即時訊息介面
  • 提及內容創作

主要特色

  • 解耦的提及顯示與選擇
  • 可自定義的建議UI
  • 跨平台支援
  • 可擴展的匹配邏輯
  • 可設定的觸發字元
  • 整合友善設計

適合對象

  • 開發人員建構豐富文字輸入
  • 需要使用者標記的應用程式
  • 需要靈活提及系統的團隊
  • 具有自定義UI需求的專案
  • Flutter 應用針對多個平台

使用建議

  • 需要自定義實作以呈現建議
  • 可能需要額外的狀態管理
  • 不適合簡單的文本輸入
  • 依賴外部邏輯進行使用者匹配
  • 有限的內建樣式選項
  • 需要仔細處理文字游標和選擇

原始 README

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

mentionable_text_field

A flutter plugin to create customizable text field that has a mentionable feature.

Installing:

In your pubspec.yaml

dependencies:
  mentionable_text_field: ^0.0.2
import 'package:mentionable_text_field/mentionable_text_field.dart';


Basic Usage:

    class _MyHomePageState extends State<MyHomePage> {
  List<Mentionable> _mentionableUsers = [];
  late void Function(Mentionable mentionable) _onSelectMention;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SafeArea(
        child: Stack(
          children: [
            Positioned(
              bottom: 0,
              width: MediaQuery.of(context).size.width,
              height: 200,
              child: Column(
                children: [
                  MentionableTextField(
                    onControllerReady: (value) =>
                    _onSelectMention = value.pickMentionable,
                    maxLines: 1,
                    onSubmitted: print,
                    mentionables: const [
                      MyUser('John Doe'),
                      MyUser('Jeanne Aulas'),
                      MyUser('Alexandre Dumas')
                    ],
                    onMentionablesChanged: (mentionableUsers) =>
                        setState(() => _mentionableUsers = mentionableUsers),
                    decoration:
                    const InputDecoration(hintText: 'Type something ...'),
                  ),
                  Expanded(
                    child: ListView.builder(
                      itemBuilder: (context, index) {
                        final mentionable = _mentionableUsers[index];
                        return ListTile(
                          leading: const Icon(Icons.person),
                          title: Text(mentionable.label),
                          onTap: () => _onSelectMention(mentionable),
                        );
                      },
                      itemCount: _mentionableUsers.length,
                    ),
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}



Custom usage

In addition to basic textField's attributes, There are other options:\

Properties Description
ValueChanged<MentionTextEditingController>? onControllerReady A callback to retrieve the TextField controller when ready
List<Mentionable> mentionables List of possible Mentionable objects, eg: users.
String escapingMentionCharacter The character used to replace mention. It should not be used by the user to avoid issues. It should be a single character.
MentionablesChangedCallback onMentionablesChanged Callback that is called on each new characters typed in TextField. It gives the current candidates to mention feature.
TextStyle mentionStyle Text Style applied to mentions

Additional information

Don't hesitate to suggest any features or fix that will improve the package!

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。