FLUTTER ECOSYSTEM

AlexisDeslandes/mentionable_text_field

一個具有提及功能的 Flutter 文本欄位

可提及的文本欄位 專案封面
Stars
6
Forks
5
最近推送(UTC)
2022年10月6日
專案狀態
未封存
Alexis Deslandes GitHub avatar
GITHUB User

Alexis Deslandes ↗

Building projects people love to use... hopefully

語言DartC++CMakeHTMLCSwiftKotlinObjective-C

此儲存庫發佈的套件

使用的依賴

依賴清單 4 項

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 README

mentionable_text_field

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

https://zupimages.net/up/22/40/1xum.gif

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!