skip to Main Content
pw.Text(descDiv, textAlign: pw.TextAlign.left,  style:const pw.TextStyle(fontSize: 10)),

but with text overflow don’t works

pw.Text(descDiv, textAlign: pw.TextAlign.left,  style:const pw.TextStyle(fontSize: 10), overflow: pw.TextOverflow.ellipsis,),

someone help me??

2

Answers


  1. Chosen as BEST ANSWER

    my solution...

    String _myElipiss(String valor) {
        //limited 18 max chars
        String retorno = "";
        if (valor.toString().length<=18) {
          retorno = valor;
        }else {
          retorno = '${valor.toString().substring(0,18)}...';
        }
        return retorno;
      }
    

  2. You can try this function

    String handleOverflow(String text, double maxWidth) {
      const ellipsis = '...';
    
      if (text.length <= 3 || maxWidth <= 0) {
        return text;
      }
    
      final ellipsisWidth = ellipsis.characters.length * 5; 
    
      while (text.length > 1 && text.length * 5 > maxWidth - ellipsisWidth) {
        text = text.substring(0, text.length - 1);
      }
    
      return text + ellipsis;
    }
    

    And use it like this

    pw.Text(
        handleOverflow(descDiv, 200), 
        textAlign: pw.TextAlign.left,
        style: pw.TextStyle(fontSize: 10),
      )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search