【问题标题】:How to Place Text Widget at the Bottom of Flutter Page?如何在 Flutter 页面底部放置 Text Widget?
【发布时间】:2022-08-07 22:08:58
【问题描述】:

我有一个这样的应用程序:

我想在页面底部放置一个Text 小部件。我怎样才能做到这一点?

代码:

import \'package:flutter/material.dart\';
import \'package:get/get.dart\';
import \'package:teen_browser/pages/LoginAndRegister/LoginPage.dart\';
import \'package:teen_browser/pages/LoginAndRegister/RegisterPage.dart\';
class RegisterPage extends StatelessWidget {
  const RegisterPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color.fromARGB(255, 25, 25, 25),
      body: SingleChildScrollView(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            SizedBox(
              height: MediaQuery.of(context).size.height * 0.05,
            ),
            Center(
              child: Image.asset(\"assets/Logo.png\", height: MediaQuery.of(context).size.height * 0.1),
            ),
            SizedBox(
              height: MediaQuery.of(context).size.height * 0.07,
            ),
            const Padding(
              padding: EdgeInsets.only(left: 15),
              child: Text(\"Ad:\", style: TextStyle(fontSize: 20, color: Colors.white)),
            ),
            SizedBox(
              height: MediaQuery.of(context).size.height * 0.01,
            ),
            Padding(
              padding: EdgeInsets.only(left: 15, right: 15),
              child: TextFormField(
                style: const TextStyle(color: Colors.white, fontSize: 18, fontFamily: \"Montserrat\"),
                decoration: InputDecoration(
                  prefixIcon: const Icon(Icons.person),
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(20.0),
                  ),
                  filled: true,
                  hintStyle: TextStyle(color: Colors.grey[600], fontFamily: \"Montserrat\"),
                  hintText: \"Ad\",
                  fillColor: Color.fromARGB(179, 55, 55, 55)
                ),
              ),
            ),
            SizedBox(
              height: MediaQuery.of(context).size.height * 0.02,
            ),
            const Padding(
              padding: EdgeInsets.only(left: 15),
              child: Text(\"Soyad:\", style: TextStyle(fontSize: 20, color: Colors.white)),
            ),
            SizedBox(
              height: MediaQuery.of(context).size.height * 0.01,
            ),
            Padding(
              padding: EdgeInsets.only(left: 15, right: 15),
              child: TextFormField(
                style: const TextStyle(color: Colors.white, fontSize: 18, fontFamily: \"Montserrat\"),
                decoration: InputDecoration(
                  prefixIcon: const Icon(Icons.person),
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(20.0),
                  ),
                  filled: true,
                  hintStyle: TextStyle(color: Colors.grey[600], fontFamily: \"Montserrat\"),
                  hintText: \"Soyad\",
                  fillColor: Color.fromARGB(179, 55, 55, 55)
                ),
              ),
            ),
            SizedBox(
              height: MediaQuery.of(context).size.height * 0.02,
            ),
            const Padding(
              padding: EdgeInsets.only(left: 15),
              child: Text(\"E-Posta:\", style: TextStyle(fontSize: 20, color: Colors.white)),
            ),
            SizedBox(
              height: MediaQuery.of(context).size.height * 0.01,
            ),
            Padding(
              padding: EdgeInsets.only(left: 15, right: 15),
              child: TextFormField(
                style: const TextStyle(color: Colors.white, fontSize: 18, fontFamily: \"Montserrat\"),
                decoration: InputDecoration(
                  prefixIcon: const Icon(Icons.mail),
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(20.0),
                  ),
                  filled: true,
                  hintStyle: TextStyle(color: Colors.grey[600], fontFamily: \"Montserrat\"),
                  hintText: \"E-Posta\",
                  fillColor: const Color.fromARGB(179, 55, 55, 55)
                ),
              ),
            ),
            SizedBox(
              height: MediaQuery.of(context).size.height * 0.02,
            ),
            const Padding(
              padding: EdgeInsets.only(left: 15),
              child: Text(\"Parola:\", style: TextStyle(fontSize: 20, color: Colors.white)),
            ),
            SizedBox(
              height: MediaQuery.of(context).size.height * 0.01,
            ),
            Padding(
              padding: const EdgeInsets.only(left: 15, right: 15),
              child: TextFormField(
                style: const TextStyle(color: Colors.white, fontSize: 18, fontFamily: \"Montserrat\"),
                decoration: InputDecoration(
                  prefixIcon: const Icon(Icons.lock),
                  prefixIconColor: const Color.fromARGB(255, 162, 162, 162),
                  border: OutlineInputBorder(
                    borderRadius: BorderRadius.circular(20.0),
                  ),
                  filled: true,
                  hintStyle: TextStyle(color: Colors.grey[600], fontFamily: \"Montserrat\"),
                  prefixStyle: TextStyle(color: Colors.grey[600]),
                  hintText: \"Parola\",
                  fillColor: const Color.fromARGB(179, 55, 55, 55)
                ),
              ),
            ),
            SizedBox(
              height: MediaQuery.of(context).size.height * 0.03,
            ),
            Padding(
              padding: const EdgeInsets.only(left: 15, right: 15),
              child: Center(
                child: Container(
                  width: MediaQuery.of(context).size.width * 0.8,
                  height: MediaQuery.of(context).size.height * 0.05,
                  child: ElevatedButton(
                    style: ElevatedButton.styleFrom(
                      backgroundColor: const Color.fromARGB(255, 47, 47, 47),
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(16), // <-- Radius
                      ),
                    ),
                    child: const Text(\"Hesap Oluştur\", style: TextStyle(color: Colors.white, fontSize: 20, fontFamily: \"Montserrat\")),
                    onPressed: () {},
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

我试过这样的代码:

Align(
  alignment: Alignment.bottomCenter,
  child: Text(\"Test\"),
),

但是这段代码不起作用。他进入了常规的Column 行。它不在页面底部。

感谢帮助。

    标签: flutter


    【解决方案1】:

    在文本小部件之前包含一个Spacer() 小部件。

    【讨论】:

      猜你喜欢
      • 2021-04-07
      • 2019-07-30
      • 1970-01-01
      • 2022-11-25
      • 2021-07-17
      • 2015-02-16
      • 2021-02-07
      • 2022-07-07
      • 2013-12-02
      相关资源
      最近更新 更多