Under which circumstances textAlign property works in Flutter?

前端 未结 8 1775
花落未央
花落未央 2020-12-07 18:19

In the code below, textAlign property doesn\'t work. If you remove DefaultTextStyle wrapper which is several levels above, textAlign s

相关标签:
8条回答
  • 2020-12-07 19:03

    You can use the container, It will help you to set the alignment.

    Widget _buildListWidget({Map reminder}) {
    return Container(
      color: Colors.amber,
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.all(20),
      height: 80,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Container(
            alignment: Alignment.centerLeft,
            child: Text(
              reminder['title'],
              textAlign: TextAlign.left,
              style: TextStyle(
                fontSize: 16,
                color: Colors.black,
                backgroundColor: Colors.blue,
                fontWeight: FontWeight.normal,
              ),
            ),
          ),
          Container(
            alignment: Alignment.centerRight,
            child: Text(
              reminder['Date'],
              textAlign: TextAlign.right,
              style: TextStyle(
                fontSize: 12,
                color: Colors.grey,
                backgroundColor: Colors.blue,
                fontWeight: FontWeight.normal,
              ),
            ),
          ),
        ],
      ),
    );
    }
    
    0 讨论(0)
  • 2020-12-07 19:06

    Specify crossAxisAlignment: CrossAxisAlignment.start in your column

    0 讨论(0)
提交回复
热议问题