Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to alight last child of row to alight completely right?

I have a ROW with 3 children.

Container(
              alignment: Alignment.center,
              margin: const EdgeInsets.all(20.0),
              child: Row(
                children: [
                  Text(
                      'hello'
                    ),
                  Padding(
                    padding: const EdgeInsets.only(left: 15.0),
                    child: SizedBox(
                        child: Text(
                      'hello'
                    )),
                  ),
                  PopupMenuButton(
                    itemBuilder: (BuildContext context) {
                      return [
                        PopupMenuItem(
                          child: Text('asdasd'),
                        )
                      ];
                    },
                  )
                ],
              ),
            )

Now I want last PopupMenuButton to completely right (Basically at the end of the containter widget.)

How can i do that?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Add a spacer()

Container(
              alignment: Alignment.center,
              margin: const EdgeInsets.all(20.0),
              child: Row(
                children: [
                  Text(
                      'hello'
                    ),
                  Padding(
                    padding: const EdgeInsets.only(left: 15.0),
                    child: SizedBox(
                        child: Text(
                      'hello'
                    )),
                  ),
                 Spacer(), //here
                  PopupMenuButton(
                    itemBuilder: (BuildContext context) {
                      return [
                        PopupMenuItem(
                          child: Text('asdasd'),
                        )
                      ];
                    },
                  )
                ],
              ),
            )

If it throws unbound error then add a width to the container

width : MediaQuery.of(context).size.width,

More about spacer

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading