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 position Text Widget inside Row?

I am trying to position my text widget right in the middle of the screen while having another icon widget inside the same row but in the right-most part of the screen.
You can see it here:

enter image description here

The aim is to position the text where the red line is.

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

my code:

Row(
                  mainAxisAlignment: MainAxisAlignment.spaceAround,
                  children: [
                    Expanded(
                        child: Text(
                            text: widget.firstJsonParam)),
                    Row(
                      children: [
                        OutlinedButton.icon(
                          //color: Colors.black,
                          onPressed: () {
                            
                            }
                          },
                          icon: Icon(Icons.edit,
                              color:
                                  Colors.black),
                          label: Text('Edit'),
                        ),
                      ],
                    ),
                  ],
                ),

>Solution :

You can use a Stack:

class Example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Card(
      child: Stack(
        children: [
          const Align(
            alignment: Alignment.center,
            child: Text('Bobby'),
          ),
          Align(
            alignment: Alignment.centerRight,
            child: OutlinedButton.icon(
              onPressed: () {},
              icon: const Icon(Icons.edit, color: Colors.black),
              label: const Text('Edit'),
            ),
          ),
        ],
      ),
    );
  }
}

enter image description here

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