desconexo / highlight_text

A flutter plugin to highlight words from a text
MIT License
30 stars 22 forks source link

Not working with Vietnamese #9

Closed binhitmobile closed 3 years ago

binhitmobile commented 4 years ago

I tried:

TextStyle textStyle = TextStyle(
          color: prefix0.orangeColor,
          fontFamily: 'Roboto-Regular',
          fontSize: ScreenUtil().setSp(45.0));
      Map<String, HighlightedWord> words = Map();
      widget.message.messageActionsModel.mentions.mentions?.forEach((user) {
        words["@all"] =
            HighlightedWord(onTap: () {}, textStyle: textStyle);
      });
      HighlightMap highlightMap = HighlightMap(words);
      return TextHighlight(
        text: widget.message.messageActionsModel.msg,
        // You need to pass the string you want the highlights
        words: highlightMap.getMap,
        // Your dictionary words
        textStyle: TextStyle(
            color: widget.isOwner ? prefix0.white : prefix0.blackColor333,
            fontFamily: 'Roboto-Regular',
            fontSize: ScreenUtil().setSp(45.0)),
        textAlign:
            TextAlign.start, // You can use any attribute of the RichText widget
      );

=> It's working fine. But if i use:

TextStyle textStyle = TextStyle(
          color: prefix0.orangeColor,
          fontFamily: 'Roboto-Regular',
          fontSize: ScreenUtil().setSp(45.0));
      Map<String, HighlightedWord> words = Map();
      widget.message.messageActionsModel.mentions.mentions?.forEach((user) {
        words["Nguyễn Hữu Bình"] =
            HighlightedWord(onTap: () {}, textStyle: textStyle);
      });
      HighlightMap highlightMap = HighlightMap(words);
      return TextHighlight(
        text: widget.message.messageActionsModel.msg,
        // You need to pass the string you want the highlights
        words: highlightMap.getMap,
        // Your dictionary words
        textStyle: TextStyle(
            color: widget.isOwner ? prefix0.white : prefix0.blackColor333,
            fontFamily: 'Roboto-Regular',
            fontSize: ScreenUtil().setSp(45.0)),
        textAlign:
            TextAlign.start, // You can use any attribute of the RichText widget
      );

=> It's not working for me. Flutter doctor -v: Screen Shot 2020-05-10 at 23 17 31

desconexo commented 3 years ago

Hi, this rework I made solved this problem