【发布时间】:2018-12-29 13:46:11
【问题描述】:
我正在尝试在AppBar 中使用来自flutter Cupertino 库 中的CupertinoSegmentedControl 使用bottom 属性来实现以下设计(高度= 32)
所以我尝试了以下方法:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 2,
backgroundColor: Colors.white,
centerTitle: true,
title: Text(this.widget.title, style: TextStyle(color: Colors.black)),
bottom: PreferredSize(
child: Padding(
padding: const EdgeInsets.only(top: 8, bottom: 12),
child: Row(
children: <Widget>[
SizedBox(width: 24),
Expanded(
child: CupertinoSegmentedControl(
children: this.widget.tabs,
groupValue: this._selectedTab,
onValueChanged: (value) {
this.setState(() => this._selectedTab = value);
this._tabController.animateTo(value);
}
),
),
SizedBox(width: 24)
],
),
),
preferredSize: Size(double.infinity, 48)
)
),
body: new TabBarView(
controller: this._tabController,
children: this.widget.views,
));
}
【问题讨论】:
-
看我的回答。不知道有没有明白你真正想要的,如果没有帮助,我会删除它。
标签: dart flutter segmentedcontrol