翩翩标题中心对齐

问题描述 投票:0回答:1

我用Container做了一个自定义的应用栏,但我需要将标题放在行的中心,后退按钮放在左侧的边缘。我确实尝试了添加隔板、mainaxisallignment等一切,但没有按照要求正确放置。那么有没有什么方法可以让我利用呢?先谢谢你了。

Widget header() {
    return new Container(
      height: 140,
      decoration: BoxDecoration(
          color: Color(0xFFAFDCEC),
          borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(20),
              bottomRight: Radius.circular(20))),
      width: MediaQuery.of(context).size.width,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          SizedBox(
            height: 60,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: <Widget>[
              IconButton(icon: Icon(Icons.arrow_back_ios, color: Colors.white,),),
              Text(
                'To-Do List',
                style: TextStyle(color: Colors.white, fontSize: 25),
              )
            ],
          )
        ],
      ),
    );
  }
flutter dart flutter-layout
1个回答
0
投票
Row(
    // mainAxisAlignment: MainAxisAlignment.spaceAround,

    children: <Widget>[

      SizedBox(width:10), //if you want to have some space (like 10px) from left edge for back button use this or wrapping IconButton with Padding with only left prameter

      IconButton(
          icon: Icon(
            Icons.arrow_back_ios,
            color: Colors.white,
          ),
          onPressed: () {}),

      Expanded(
        child: Center(
          child: Text(
            'To-Do List',
            style: TextStyle(color: Colors.white, fontSize: 25),
          ),
        ),
      ),

    ],
)
© www.soinside.com 2019 - 2024. All rights reserved.