skip to Main Content

I want to change the position of the text in this ElevatedButton, how to make it from the center to the right or left

I tried using the TextAlign but it didn’t work…

2

Answers


  1. Chosen as BEST ANSWER

    It's fine I found a solution...

    You can use something like this:

    Align(
        alignment: Alignment.centerRight,
            child:
                Text(
                    'Button Text',
                     style: TextStyle(fontSize: 25, color: Color(White), fontWeight: FontWeight.bold),
                      )
                    )),
    

  2. You can specify style for button and make needed padding.

    Like in the example below I set padding from the left 16 and from the right 0.

    ElevatedButton(
      style: ElevatedButton.styleFrom(
            padding: const EdgeInsetsDirectional.only(
              start: 16,
              top: 8,
              end: 0,
              bottom: 8,
            ),
          ),
          child: const Text('Click'),
          onPressed: () {},
        )
    

    Result can see in the image below

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search