【问题标题】:Flutter Title center-allignmentFlutter Title 中心对齐
【发布时间】:2020-09-21 18:53:40
【问题描述】:

我使用 Container 制作了一个自定义应用栏,但我需要将标题放置在行的中心,并将后退按钮放置在左侧的边缘。 我确实通过添加垫片、主轴对齐所有东西来尝试它,但它没有按要求正确放置。那么有什么我可以使用的方法吗?提前致谢。

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】:
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),
          ),
        ),
      ),

    ],
)

【讨论】:

  • 从您的代码中,标题从中心开始,但我需要将标题放在中心
猜你喜欢
  • 2023-03-16
  • 1970-01-01
  • 2013-11-27
  • 1970-01-01
  • 2018-09-26
  • 2020-05-14
  • 2021-12-21
  • 2016-09-13
  • 1970-01-01
相关资源
最近更新 更多