Flutter 颤振位置按钮
我需要一个特定位置的按钮。 职位应为: 中心水平,中心垂直,例如500px 有人知道怎么做吗?1。您可以使用堆栈内的定位小部件包装按钮,使其顶部为500,并为堆栈设置alignment:alignmentdirective.center以使其子项居中:Flutter 颤振位置按钮,flutter,dart,Flutter,Dart,我需要一个特定位置的按钮。 职位应为: 中心水平,中心垂直,例如500px 有人知道怎么做吗?1。您可以使用堆栈内的定位小部件包装按钮,使其顶部为500,并为堆栈设置alignment:alignmentdirective.center以使其子项居中: @override Widget build(BuildContext context) { return Scaffold( body: Stack( alignment: AlignmentDirect
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
Positioned(
top: 500,
child: RaisedButton(
color: Colors.yellow,
onPressed: () { },
child: Text('press me'),
)
),
]
)
);
}
绝对位置使用“对齐”,相对位置使用“定位”
这是一个好主意
@override
Widget build(BuildContext context) {
return Scaffold(
body: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
margin: const EdgeInsets.only(top: 500),
child: RaisedButton(
color: Colors.yellow,
onPressed: () { },
child: Text('press me'),
)
)
]
)
);
}