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 place first item at start, then second item of column directly in center?

I think I am not seeing a simple solution to this, but I want to have purple icon and text at the same height as black icon, when I have purple divider in first example as first item
enter image description here

Here is how my code of this purple Column look like:

Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                Container(
                  height: 4,
                  width: size.width * 0.22,
                  color: Colors.deepPurple,
                ),
                const Column(
                  children: [
                    Icon(
                      Icons.home,
                      color: Colors.deepPurple,
                    ),
                    Text(
                      'Strona główna',
                      style: TextStyle(
                          color: Colors.deepPurple
                      ),
                    )
                  ],
                ),
              ],
            ),

I tried using Expanded or Spacer but it didnt work for me.

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 :

If this is the result you are looking for

enter image description here

You can use mainAxisAlignment: MainAxisAlignment.center for the outer Column widget, and put the inner Column inside Expanded and Padding.

This is the code:

Column(
  mainAxisAlignment: MainAxisAlignment.center, // Changed this!
  children: [
    Container(
      height: 4,
      width: size.width * 0.22,
      color: Colors.deepPurple,
    ),
    const Expanded(
      child: Padding(
        padding: EdgeInsets.only(top: 13.0), // Change this if not in the middle
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Icon(
              Icons.home,
              color: Colors.deepPurple,
            ),
            Text(
              'Strona główna',
              style: TextStyle(color: Colors.deepPurple),
            )
          ],
        ),
      ),
    ),
  ],
),
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