How to solve: position icon of ElevatedButton.icon to the right

Question

Asked by Kavishka R on November 22, 2021 (source).

I've got an elevated button with an icon where the icon is placed left to the text using ElevatedButton.icon. What I actually want is to place the icon to the right of the text. How can I do it my code :

    ElevatedButton.icon(
        onPressed: onPressed,
        icon:Icon(icon,
          color: color != null ? color : null,
          size: getIconSize(),
        ),
        label: Text(label),
        style: buttonStyle);

How it looks :

enter image description here

what I want :

Next ->

Answer

Question answered by s.am.i (source).

Use Directionality widget. Make the direction rtl.

Directionality(
      textDirection: TextDirection.rtl,
      child: ElevatedButton.icon(
        onPressed: () {},
        icon: Icon(
          Icons.arrow_back,
        ),
        label: Text("Test"),
     //.........
      ))

Now, you just need to add your style

enter image description here

DART FLUTTER FLUTTER-LAYOUT
SHARE: