v0.0.2mentionable_text_field
사용자 언급 기능을 가진 사용자 정의 가능한 텍스트 필드를 생성하는 플러터 플러그인입니다. 일치하는 사용자를 표시하고 선택하는 방식은 위젯 자체와 분리되어 있어, 원하는 방식으로 선택할 수 있습니다.
35좋아요 10530일 다운로드130Pub 점수
AndroidiOSWebmacOSWindowsLinux
멘션 기능이 있는 플러터 텍스트 필드
{"sdk":"flutter"}{"sdk":"flutter"}^0.3.0^3.0.1아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
A flutter plugin to create customizable text field that has a mentionable feature.
https://zupimages.net/up/22/40/1xum.gif
In your pubspec.yaml
dependencies:
mentionable_text_field: ^0.0.2
import 'package:mentionable_text_field/mentionable_text_field.dart';
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,
),
)
],
),
)
],
),
),
);
}
}
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 |
Don't hesitate to suggest any features or fix that will improve the package!