如何移动容器位置?

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

我希望我的容器还剩一点位置。我尝试使用填充,但无法正常工作。下面是我的代码容器(颜色:蓝色,

    //padding: EdgeInsets.all(10),
    child: Row(

      children: <Widget>[

        Padding(
          child: new Text(
              'BIKE DETAILS',
              style: new TextStyle(
                  fontWeight: FontWeight.bold, fontSize: 20.0),
              textAlign: TextAlign.left,

            ),
          padding: EdgeInsets.only(bottom: 20.0),),
          SizedBox(width: 20),


    ),
  ),
    ],

I Want the blue container to move little bit left.

flutter flutter-layout
1个回答
0
投票

以下代码将蓝色容器向左移动。如果您想向右移动文本,请像以前一样用Padding小部件包裹文本。或将文本包装在container中,然后使用EdgeInsets根据需要提供特定的填充。

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('text'),
      ),
      body: Container(
        color: Colors.blue,
        height: 50, //change to your desired height.
        width:
            MediaQuery.of(context).size.width, //change to your desired width.
        /// Below in the margin parameter EdgeInsets.fromLTRB will help you give specific
        /// margins from Left, Top, Right and Bottom respectively.
        margin: EdgeInsets.fromLTRB(5, 20, 5, 20),
        child: Row(
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(10.0),
              child: Text(
                'BIKE DETAILS',
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
                textAlign: TextAlign.left,
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(10.0),
              child: Text(
                'BIKE DETAILS',
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
                textAlign: TextAlign.left,
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Output of the Code

希望这会有所帮助!

© www.soinside.com 2019 - 2024. All rights reserved.