我有一个列包含一些小部件(下图),我试图将文本(没有帐户注册)置于其上方的按钮和屏幕底部之间的中心。任何解决方案将不胜感激,谢谢 和
这是迄今为止我的代码:
Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Align(
alignment: Alignment.center,
child: Text(
"or",
style: TextStyle(fontSize: 16, color: Colors.black),
),
),
Container(
margin: const EdgeInsets.only(top: 10),
width: MediaQuery.of(context).size.width,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(backgroundColor: const Color(0xFFD9D9D9), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))),
child: const Padding(
padding: EdgeInsets.symmetric(vertical: 12.0),
child: Text(
"Continue",
style: TextStyle(fontSize: 16, color: Colors.black),
),
)),
),
const SizedBox(
height: 20,
),
const Align(
alignment: Alignment.bottomCenter,
child: Text(
"Don’ have an account? Sign up",
style: TextStyle(fontSize: 16, color: Color(0x80000000)),
),
),
],
);
尝试使用文本上方的
Spacer
没有帐户?报名?并在其下方使用 SizedBox
留出一些空间,然后使用容器将其对齐中心,如下所示
不知道这是不是你想要的..
Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Align(
alignment: Alignment.center,
child: Text(
"or",
style: TextStyle(fontSize: 16, color: Colors.black),
),
),
Container(
margin: const EdgeInsets.only(top: 10),
width: MediaQuery.of(context).size.width,
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFD9D9D9),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10))),
child: const Padding(
padding: EdgeInsets.symmetric(vertical: 12.0),
child: Text(
"Continue",
style: TextStyle(fontSize: 16, color: Colors.black),
),
)),
),
Spacer(),
Container(
alignment: Alignment.center,
child: Text(
"Don’ have an account? Sign up",
style: TextStyle(fontSize: 16, color: Color(0x80000000)),
),
),
SizedBox(
height: 20,
)
],
),