【发布时间】:2019-06-23 20:27:58
【问题描述】:
我想在 Stack 的顶部中心放置一个小部件,但它被拉伸到父级的宽度,如下面的屏幕截图:
这是我正在使用的代码:
@override
Widget build(BuildContext context) {
return Scaffold(
key: key,
appBar: AppBar(
title: Text("Just a test app"),
),
body: Stack(
children: <Widget>[
Positioned(
left: 0,
right: 0,
child: Card(
child: Text("A variable sized text"),
),
),
],
),
);
}
【问题讨论】: