i’m trying to implemment mention function for my app like FB,Zalo, whatsapp. I’m almost done using the flutter_mentions library. Except i can’t figure out how to implement this function “a user can only be tagged once”.
when user A is mentioned, then we can’t mention duplicate A. So how to implement such a function? Thanks
I’m trying to delete user mention has been chosen on onSearchChanged, but after that an user mention before has been remove from markup too(missing blue highlight). You can see this in my attach image.
enter image description here
onSearchChanged:
(String trigger, String value) {
if (trigger == "@") {
if (_debounce?.isActive ?? false)
_debounce!.cancel();
_debounce = Timer(
const Duration(milliseconds: 200),
() {
setState(() {
mentiondata.clear();
final List<Map<String, dynamic>>
mentionTemp = [];
mentionTemp.addAll([
{
"id": "3",
"display": "fayeedP",
"photo":
"https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg"
},
{
"id": "5",
"display": "khaled",
"photo":
"https://images.pexels.com/photos/220453/pexels-photo-220453.jpeg",
},
]);
String text = _bloc.key.currentState!
.controller!.markupText;
RegExp regex = RegExp(
r"@[__([a-zA-Z0-9]+)__]");
Iterable<Match> matches =
regex.allMatches(text);
List<String> results = [];
for (Match match in matches) {
results.add(match.group(1)!);
}
results.forEach((item) {
mentionTemp.removeWhere((element) =>
element['id'] == item);
});
mentiondata = mentionTemp;
});
});
}
},
Try using flutter_mentions lib.
My expecting: complete this function