简体   繁体   中英

different text direction for different lines for a poem text in flutter

image1 , image2 I want to fetch text from Json file and show the text in different text direction for different lines

Trying to build with a listview.builder Is it possible

Good, as it show up in the image the text seems to be always alternate, so you can apply a validation to alternate with the index. Try change the textDirection detecting if the index is odd or even.

ListView.builder(
  AlwaysScrollableScrollPhysics()),
    itemCount: this.yourValue.length,
    itemBuilder: (BuildContext ctx, int index){

      return YourBuildList(this.yourValue[index],
              index.floor().isEven ? true : false); //here you can handle. If is even is TextAlign.start. If it is odd is TextAlign.end or vice versa
}),

As i said before, with a code example the anwers could be better, greetings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM