I solved this solution using the alignment property. Idk whether this is the correct solution or a workaround.
First I made the Stack that contains the text to take the entire width of its parent.
Since the parent element was made using a ForEach, the text will be only displayed in some indices of List.
and I created a function like this
func textAlignment (currentIndex: int, totalIndex:Int) -> Alignment { if (currentIndex == 0){ return Alignment.leading } if (currentIndex == totalIndex-1){ return Alignment.trailing } return Alignment.center }
and I added this to Text stack using .frame(alignment: textAlignment ()) property.