Under which circumstances textAlign property works in Flutter?

前端 未结 8 1807
花落未央
花落未央 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: [
          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,
              ),
            ),
          ),
        ],
      ),
    );
    }
    

提交回复
热议问题