简体   繁体   English

Flutter 文本不居中

[英]Flutter Text Is Not Centered

I have a code like this:我有这样的代码:

return Scaffold(
  backgroundColor: const Color.fromARGB(255, 25, 25, 25),
  body: Padding(
    padding: EdgeInsets.all(5),
    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        const Text("Güvenli ve Gizli", style: TextStyle(fontSize: 32, color: Colors.white, fontWeight: FontWeight.bold)),
        SizedBox(height: MediaQuery.of(context).size.height * 0.02),
        AnimatedBuilder(
          animation: ezAnimation,
          builder: (context, snapshot) {
            return Center(
              child: Image.asset("assets/SecureAndHiddenIcon.png", fit: BoxFit.cover, color: Colors.white, height: 200)
            );
          }
        ),
        SizedBox(height: MediaQuery.of(context).size.height * 0.02),
        Center(child: Text("Kullanıcıya değer vermek, güvenlik ve gizliliği sağlamaktan başlar. Malum tarayıcılar gibi bilgilerinizi satmayız!", style: TextStyle(fontSize: 18, color: Colors.white))), // !!!!!!!!!!!!! <<<<<<<<<<<<<<<
      ],
    ),
  ),
);

"Kullanıcıya değer vermek, güvenlik ve gizliliği sağlamaktan başlar. Malum tarayıcılar gibi bilgilerinizi satmayız!" “Kullanıcıya değer vermek, güvenlik ve gizliliği sağlamaktan başlar. Malum tarayıcılar gibi bilgilerinizi satmayız!” written Text is not centered even though it is inside the Center widget.书面Text没有居中,即使它位于Center小部件内。 Why does this problem occur?为什么会出现这个问题? How to I solve it?我该如何解决?

Hey did you try textAlign property of Text widget like this - textAlign: TextAlign.center嘿,您是否尝试过这样的 Text 小部件的 textAlign 属性 - textAlign: TextAlign.center

return Scaffold(
  backgroundColor: const Color.fromARGB(255, 25, 25, 25),
  body: Padding(
    padding: EdgeInsets.all(5),
    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        const Text("Güvenli ve Gizli", style: TextStyle(fontSize: 32, color: Colors.white, fontWeight: FontWeight.bold)),
        SizedBox(height: MediaQuery.of(context).size.height * 0.02),
        AnimatedBuilder(
          animation: ezAnimation,
          builder: (context, snapshot) {
            return Center(
              child: Image.asset("assets/SecureAndHiddenIcon.png", fit: BoxFit.cover, color: Colors.white, height: 200)
            );
          }
        ),
        SizedBox(height: MediaQuery.of(context).size.height * 0.02),
        Center(child: Text("Kullanıcıya değer vermek, güvenlik ve gizliliği sağlamaktan başlar. Malum tarayıcılar gibi bilgilerinizi satmayız!",textAlign: TextAlign.center, style: TextStyle(fontSize: 18, color: Colors.white))), // !!!!!!!!!!!!! <<<<<<<<<<<<<<<
      ],
    ),
  ),
);

请尝试使用对齐小部件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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