Flutter 如何在Flatter中创建没有应用程序栏的选项卡栏?
我希望在我的主屏幕上添加标签应用程序而不是应用程序栏。如何创建它。目前,我的标签栏添加在应用程序栏的底部,我已经删除了标题和立面。同时,我不能说Flutter 如何在Flatter中创建没有应用程序栏的选项卡栏?,flutter,Flutter,我希望在我的主屏幕上添加标签应用程序而不是应用程序栏。如何创建它。目前,我的标签栏添加在应用程序栏的底部,我已经删除了标题和立面。同时,我不能说appBar:null,因为我需要在选项卡栏顶部留出一些空间 Widget HomeTap = new Scaffold( appBar: new AppBar( bottom: new TabBar( indicatorColor: Colors.pinkAccent[100], labelColor: Colors.pinkAcc
appBar:null
,因为我需要在选项卡栏顶部留出一些空间
Widget HomeTap = new Scaffold(
appBar: new AppBar(
bottom: new TabBar(
indicatorColor: Colors.pinkAccent[100],
labelColor: Colors.pinkAccent[100],
indicatorWeight: 0.5,
unselectedLabelColor: Colors.grey[400],
tabs: [
new Tab(text: 'Album',),
new Tab(text: 'Artist'),
new Tab(text: 'Playlist'),
new Tab(text: 'Songs'),
new Tab(icon: new Icon(Icons.search))
]),
title: null,
elevation: 0.0,
),
body: new TabBarView(
children: [
new Center(
child: new AlbumWidget(),
),
new Container(),
new Container(),
new Container(),
new Container(),
],
),
);
弗利特与构图一起工作。您几乎可以用其他东西替换任何小部件。他们不限于一个特定的孩子 所以你可以简单的做
new Scaffold(
appBar: new TabBar(
...
),
...
)
唯一的要求是小部件具有正确的接口。
脚手架需要asappBar
aPreferredSizeWidget
幸运的是,TabBar
在默认情况下已经是一个PreferredSizeWidget
。因此无需更改@覆盖
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
title: Text('Tabs Demo'),
),
body:
Column(
children: <Widget>[
TabBar(
tabs: [
Tab(icon: Icon(Icons.directions_car)),
Tab(icon: Icon(Icons.directions_transit)),
Tab(icon: Icon(Icons.directions_bike)),
],
),
Expanded(
flex: 1,
child: TabBarView(
children: [
Icon(Icons.directions_car),
Icon(Icons.directions_transit),
Icon(Icons.directions_bike),
],
),
)
],
)
),
),
);
小部件构建(构建上下文){
返回材料PP(
主页:DefaultTabController(
长度:3,
孩子:脚手架(
appBar:appBar(
标题:文本(“选项卡演示”),
),
正文:
纵队(
儿童:[
塔巴(
选项卡:[
选项卡(图标:图标(图标方向车)),
选项卡(图标:图标(图标方向和交通)),
选项卡(图标:图标(图标方向)),
],
),
扩大(
弹性:1,
子项:选项卡视图(
儿童:[
图标(图标、方向和汽车),
图标(图标、方向和交通),
图标(图标、方向和自行车),
],
),
)
],
)
),
),
);
这对我有效尝试flexibleSpace
return DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
flexibleSpace: new Column(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
TabBar(
tabs: [
Tab(text: "Pending"),
Tab(text: "Delivered"),
Tab(text: "Rejected"),
],
)
],
),
),
body: TabBarView(
children: [
PendingOrders(),
DeliveredOrders(),
RejectedOrders(),
],
),
),
);
返回DefaultTabController(
长度:3,
孩子:脚手架(
appBar:appBar(
flexibleSpace:新列(
mainAxisAlignment:mainAxisAlignment.end,
儿童:[
塔巴(
选项卡:[
选项卡(文本:“待定”),
选项卡(文本:“已交付”),
选项卡(文本:“已拒绝”),
],
)
],
),
),
正文:选项卡视图(
儿童:[
PendingOrders(),
发货人(),
拒绝订单(),
],
),
),
);
如果我们添加appBar:new TabBar
那么我在哪里添加TabBarView
。目前,我已经添加到脚手架的主体中。此处没有更改。仍然在脚手架中当我这样做时,TabBar显示在状态栏的正下方。即使它在脚手架中。一个缺点是颜色主题消失了