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

Flutter | Text position inside of card

I’m currently coding a timer on Flutter here’s my code and screenshoot. I’m pretty new to flutter but every fix I tried to this don’t work.

THE APP UI

And here’s my code:

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

        body: Stack(
          children: [
            Positioned(
              left: 20,
              right: 20,
              child: Card(
                color: Color.fromRGBO(44, 47, 93, 1),
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(50)),
                child: InkWell(
                  child: SizedBox(
                    width: 342,
                    height: 344,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: [
                        Container(
                          child: Text(
                            'POMODORO',
                            style: TextStyle(
                                color: Colors.white, 
                                fontFamily: 'SFPro',
                                fontSize: 12
                            ),
                          ),
                        ),
                        Container(
                          child: Text(
                            'SHORT BREAK',
                            style: TextStyle(
                                color: Colors.white, 
                                fontFamily: 'SFPro',
                                fontSize: 12
                            ),
                          ),
                        ),
                        Container(
                          child: Text(
                            'LONG BREAK',
                            style: TextStyle(
                                color: Colors.white, 
                                fontFamily: 'SFPro',
                                fontSize: 12
                            ),
                          ),
                        )
                      ], // Children
                    ),
                  ),
                ),
              ),
            )
          ], // Children
        ),
      ),
    );
  }
}

I have a question:

  1. How can I move the 3 Pomodoro, Short Break and Long Break to the top of the card?

Thanks a lot!

>Solution :

Use crossAxisAlignment: CrossAxisAlignment.start in the Row plus add a padding to SizedBox as follows

SizedBox(
                    
                    width: 342,
                    height: 344,
                    child: Padding(
                    padding: EdgeInsets.all(8),
                    child: Row(
                      
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: [
                        Container(
                          child: Text(
                            'POMODORO',
                            style: TextStyle(
                                color: Colors.white, 
                                fontFamily: 'SFPro',
                                fontSize: 12
                            ),
                          ),
                        ),
                        Container(
                          child: Text(
                            'SHORT BREAK',
                            style: TextStyle(
                                color: Colors.white, 
                                fontFamily: 'SFPro',
                                fontSize: 12
                            ),
                          ),
                        ),
                        Container(
                          child: Text(
                            'LONG BREAK',
                            style: TextStyle(
                                color: Colors.white, 
                                fontFamily: 'SFPro',
                                fontSize: 12
                            ),
                          ),
                        )
                      ], // Children
                    ),)
                  ),
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