Home > OS >  Multiple child in flutter
Multiple child in flutter

Time:11-05

i want to add another MaterialButton under the first one. I got the first Button and a want to add multiple ones.

body: SingleChildScrollView(
    child: Padding(
      padding: EdgeInsets.only(top: 15, bottom: 0, left: 5, right: 5),
      child: MaterialButton(
        onPressed: () {},
        child: Container(
            height: 180,
            width: double.infinity,
            decoration: BoxDecoration(
              color: Colors.grey[300],
              borderRadius: BorderRadius.circular(20.0),
            ),),)

CodePudding user response:

If you want to Add Multiple Buttons and if you want to align them horizontally, then enclose the buttons inside a Row Widget. If you want to Align them Vertically, Enclose them inside a Column Widget.

If you want to have both Horizontally and Vertically aligned Make the Parent Widget as Column and have multiple children of Row Widgets and The Row can have Buttons as children

CodePudding user response:

You can create 2 buttons inside a column

body: return SingleChildScrollView  (
        child: Padding(
        padding: EdgeInsets.only(top: 15, bottom: 0, left: 5, right: 5),
        child: Row(
          children: [
            Expanded(
              child: MaterialButton(
              onPressed: () {},
              child: Container(
              height: 180,
              width: double.infinity,
              decoration: BoxDecoration(
                color: Colors.grey[300],
                borderRadius: BorderRadius.circular(20.0),
                ),
              )
            ),
            ),
            Expanded(
              child: MaterialButton(
              onPressed: () {},
              child: Container(
              height: 180,
              width: double.infinity,
              decoration: BoxDecoration(
                color: Colors.grey[300],
                borderRadius: BorderRadius.circular(20.0),
                ),
              )
            ),
            ),
            Expanded(
              child: MaterialButton(
              onPressed: () {},
              child: Container(
              height: 180,
              width: double.infinity,
              decoration: BoxDecoration(
                color: Colors.grey[300],
                borderRadius: BorderRadius.circular(20.0),
                ),
              )
            ),
            ),
          ],
        ),
        )
    );
  • Related