flutter wrap text code example

Example 1: text overflow in new line in flutter

Row(
     children: [
                Flexible(
                  child: Text('Add long text here',
                  maxLines: 1,
                  softWrap: false,
                  overflow: TextOverflow.fade,
                  ),
                ),
              ],
            )

Example 2: text wrap flutter

//80% of screen width
    double c_width = MediaQuery.of(context).size.width*0.8;

    return new Container (
      padding: const EdgeInsets.all(16.0),
      width: c_width,
      child: new Column (
        children: <Widget>[
          new Text ("Long text 1 Long text 1 Long text 1 Long text 1 Long text 1 Long text 1 Long text 1 Long text 1 Long text 1 Long text 1 Long text 1 Long text 1 Long text 1 Long text 1 ", textAlign: TextAlign.left),
          new Text ("Long Text 2, Long Text 2, Long Text 2, Long Text 2, Long Text 2, Long Text 2, Long Text 2, Long Text 2, Long Text 2, Long Text 2, Long Text 2", textAlign: TextAlign.left),
        ],
      ),
    );

Tags:

Dart Example