Flutter: Trying to bottom-center an item in a Column, but it keeps left-aligning

后端 未结 11 2173
广开言路
广开言路 2020-12-07 18:54

I\'m trying to bottom-center a widget at the bottom of a Column, but it keeps aligning to the left.

return new Column(
  new Stack(
    new Positioned(
              


        
11条回答
  •  萌比男神i
    2020-12-07 19:13

    To do this easily, the use of Stack is better. Create a Stack Then inside Stack add Align or Positioned and set position according to your needed, You can add multiple Container.

    Container
      child: Stack(
        children: [
          Align(
             alignment: FractionalOffset.center,
             child: Text(
                "₹ 1000",
             )
          ),
          Positioned(
            bottom: 0,
            child: Container(
               width: double.infinity,
               height: 30,
               child: Text(
                 "Balance", ,
               )
             ),
           )
        ],
      )
    )
    

    Stack a widget that positions its children relative to the edges of its box.

    Stack class is useful if you want to overlap several children in a simple way, for example having some text and an image, overlaid with a gradient and a button attached to the bottom.

提交回复
热议问题