I'm currently working on a button, which has 3 elements: An icon (with a fixed size), a title (f.e Buy Now!) and the price of the item. The price which should be displayed is adaptive, this could be €2,00 or €2000,00. The title is supposed to be centered, based on the Button itself, rather than the area it can occupy.
The price of object has the priority within the button, and should always be fully displayed with a set style. Due to this, the size of this object is variable, and can not be determined beforehand.
When the length of the price object increases, naturally the available space of the title decreases. However, when attempting to center the text, I could only get it to center based on the available space, which resulted in the text being off-center.

How could one approach this issue, allowing for the text to be centered based on the parent (button), rather than the available text size?

You can try this:
The
Buttonhas a content parameter you can use to set its content, in this case we use aRowto set contents in the horizontal axis.Note that each of the components,
IconTextandTextare wrapped inside aBoxwith aweightof1f, making each those boxes as their container that also takes equal divided space of the parentRow.The middle
Boxpositions its child in the center, while the first and lastBoxpositions their children (i.eIconandText) inTopStartandTopEndalignment, though you don't need to worry the "top" positioning as its neglected here because the parentRowaligns all its childrencenter-verticallyIf we put a
backgroundcolor on eachBox,we can clearly see their equal
width