Текст выравнивать, выравнивать - PullRequest
0 голосов
/ 31 марта 2020

Можно ли сделать мой текст нормальным, то есть без пробелов между словами? Есть ли способ обернуть слова в следующую строку, разделив их?

снимок экрана

желаемый результат

Это код моего текстового раздела.

Widget textSection({String leadingTitle, String title, String content, BuildContext context}) {
      return Row(
        children: <Widget>[
          Material(
            shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
            color: Colors.red,
            child: Container(
              padding: EdgeInsets.all(5.0),
              child: Text(leadingTitle,
                  style: TextStyle(
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                      fontSize: 18.0)),
            ),
          ),
          SizedBox(
            width: 10.0,
          ),
          Expanded(
            child: Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
              children: <Widget>[
                Text(
                  text: content,
                  textAlign: TextAlign.justify,

                  style: TextStyle(
                      fontFamily: 'verdana', color: Colors.black, fontSize: 14), 
                )
              ],
            ),
          )
        ],
      );
    }

1 Ответ

0 голосов
/ 31 марта 2020

Измените свой код на:

Widget textSection({String leadingTitle, String title, String content, 
BuildContext context}) {
  return Row(
    children: <Widget>[
      Material(
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
        color: Colors.red,
        child: Container(
          padding: EdgeInsets.all(5.0),
          child: Text(leadingTitle,
              style: TextStyle(
                  color: Colors.white,
                  fontWeight: FontWeight.bold,
                  fontSize: 18.0)),
        ),
      ),
      SizedBox(
        width: 10.0,
      ),
      Expanded(
        child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Text(
              text: content,

              //this was TextAlign.justify
              textAlign: TextAlign.left, // will now left justify your text

              style: TextStyle(
                  fontFamily: 'verdana', color: Colors.black, fontSize: 14), 
            )
          ],
        ),
      )
    ],
  );
}
...