flutter 如何使文本在所有屏幕上对齐像这样

disho6za  于 2023-05-19  发布在  Flutter
关注(0)|答案(2)|浏览(137)

文本在一个设备上工作很好,但在其他屏幕上的文本是凌乱的,所以请帮助我减少这个容器的规模,我想让它运行在所有屏幕上像这样的图像image preview example和输出在我的屏幕上是这样的,但在其他屏幕上是凌乱的

Container(
              width: 350,
              child: FutureBuilder(
                future: GetJuz(),
                builder: (context, snapshot) {
                  if (snapshot.connectionState == ConnectionState.waiting) {
                    return Center(child: CircularProgressIndicator());
                  } else {
                    var ayat = snapshot.data!;
                    var ayah = "";
                    for (var i = 12; i < 23; i++) {
                      ayah += ayat[i].codes!.replaceAll(" ", "");
                    }

                    return Container(
                      child: RichText(
                        textDirection: TextDirection.rtl,
                        text: TextSpan(
                          children: [
                            for (var element in ayat) ...[
                              if (element.page == "5")
                                TextSpan(
                                  text: element.codes
                                      .toString()
                                      .replaceAll(" ", ""),
                                  recognizer: TapGestureRecognizer()
                                    ..onTap = () {
                                      print(element.text);
                                    },
                                  style: TextStyle(
                                    fontFamily: 'Schyler',
                                    fontSize:
                                        MediaQuery.of(context).size.width *
                                            0.05,
                                    color: Colors.black,
                                  ),
                                ),
                            ],
                          ],
                        ),
                      ),
                    );
                  }
                },
              ),
            ),
7nbnzgx9

7nbnzgx91#

fontSize: MediaQuery.of(context).size.width * 0.05, // This will adjus the font size

我不确定这个,但你试试看

gc0ot86w

gc0ot86w2#

我认为你希望文本从两端对齐。如果是这样的话,您可以在RichText中使用它

RichText(
      textAlign: TextAlign.justify,
      ......
)

相关问题