Home > Software engineering >  flutter place widget on bottom of screen in expanded
flutter place widget on bottom of screen in expanded

Time:02-27

like the title says is there a way to place a widget on bottom of screen in expanded

Expanded -> SingleChildScrollView() -> column(children: [ -> Container() -> ElevatedButton() ])

i want the ElevatedButton to be placed on the bottom of screen also i don't want to place it away of the Expanded widget, is there a way to do that ?

CodePudding user response:

Expanded(
  child: Column(
     children: [
       Container(),
       //use Spacer(),
       Spacer(),
       ElevatedButton()
     ],
     
   ),
)

try use spacer inside column

CodePudding user response:

SingleChildScrollView(
    child: Container(
      height: MediaQuery.of(context).size.height - APPBAR_SIZE,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Container(child: CHILD),
          ElevatedButton(),
        ],
      ),
    ),
  )

UPDATE:

Column(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      Container(
        height: MediaQuery.of(context).size.height - APPBAR_SIZE - ElevatedButtonHeight,
        child: SingleChildScrollView(
          child: Container(child: CHILD),
        ),
      ),
      ElevatedButton(),
    ],
  ),
  • Related