【发布时间】:2019-09-11 05:02:34
【问题描述】:
我在屏幕顶部有一个选项卡布局,在屏幕底部有一个底部导航视图。
我需要在中间有一个容器并交换视图,这类似于 Android 中的片段事务。
如何在 Flutter 中实现这一点?
home: DefaultTabController(
length: prefList.length,
child: Scaffold(
appBar: AppBar(
backgroundColor: const Color(0xff00234a),
bottom: TabBar(
tabs: tabList,
isScrollable: true,
indicatorColor: const Color(0xffffffff),
),
title: Text('Test Demo'),
centerTitle: true,
),
body: Container(
child: TabBarView(
children: tabList,
controller: controller,
),
),
// Set the bottom navigation bar
bottomNavigationBar: Material(
// set the color of the bottom navigation bar
color: const Color(0xff00234a),
// set the tab bar as the child of bottom navigation bar
child: TabBar(
tabs: <Tab>[
Tab(
icon: Icon(Icons.favorite),
),
Tab(
icon: Icon(Icons.adb),
),
Tab(
icon: Icon(Icons.airplay),
),
Tab(
icon: Icon(Icons.gamepad),
),
Tab(
icon: Icon(Icons.videogame_asset),
),
],
// setup the controller
controller: controller,
),
),
),
),
);
}
我需要将 TabView 小部件替换为 Android 中用于替换不同片段的容器布局之类的东西!
【问题讨论】:
-
顶部的TabBar 和底部的TabBar 是一样的吗? TabView,在Android上具有作为片段过渡的滑动效果。您想创建一个自定义布局小部件以在不同页面上重复使用它吗?
标签: flutter