【发布时间】:2021-05-02 15:04:28
【问题描述】:
我是 Flutter 的新手,我需要有关 align 小部件的帮助 这里使用了 TabBar 小部件的对齐中心和 文本小部件的对齐右下角 我在这里没有得到正确的结果。
这是输出图像:
源代码:
Widget build(BuildContext context) {
var screenSize = MediaQuery.of(context);
return SafeArea(
child: DefaultTabController(
length: 2,
child: Scaffold(
backgroundColor: Colors.amber,
body: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
*[**alignment: Alignment.bottomRight,**][1]*
child: Text("data"),
),
Align(
***alignment: Alignment.center,***
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: 300,
maxHeight: 60,
),
child: AppBar(
automaticallyImplyLeading: false,
bottom: TabBar(
tabs: [
Tab(
icon: Icon(Icons.directions_bike),
),
Tab(
icon: Icon(
Icons.directions_car,
),
),
],
),
),
),
),
ConstrainedBox(
constraints: BoxConstraints(
maxHeight: 100,
maxWidth: 100,
),
child: Container(
color: Colors.blue,
),
)
],
),
),
),
);
}
【问题讨论】:
-
那么你想在哪里显示你的文本数据? bottomRight 表示在屏幕的末尾
-
是的,TabBar 位于中心
标签: flutter widget alignment flutter-layout