Closed rifkiard closed 10 months ago
@rifkiard coincidentally, I have been working on making this possible and only had to make some finishing touches when I saw the notification of your issue.
I've sped that up thanks to you! You can use multiple triggers in v2.0.0 of FlutterTagger. The API has changed a little to accommodate this.
FlutterTagger(
controller: flutterTaggerController,
onSearch: (query, triggerCharacter) {
//perform search
},
//characters that can trigger a search and the styles
//to be applied to their tagged results in the TextField
triggerCharacterAndStyles: const {
"@": TextStyle(color: Colors.pinkAccent),
"#": TextStyle(color: Colors.blueAccent),
},
overlay: SearchResultView(),
builder: (context, containerKey) {
//return child TextField wrapped with a Container
//and pass it `containerKey`
return Container(
key: containerKey,
child: TextField(
controller: flutterTaggerController,
suffix: IconButton(
onPressed: () {
//get formatted text from controller
final text = flutterTaggerController.formattedText;
//perform send action...
FocusScope.of(context).unfocus();
flutterTaggerController.clear();
},
icon: const Icon(
Icons.send,
color: Colors.redAccent,
),
),
),
);
},
)
You can also take a look at the example project where I added an example demo for both user mentions and hashtags. I hope this helps.
Aye, thank you!
I want to create a form field that can mention users and tags in one controller, how can it be done?