在 TabBar 外面再套一層 Material ,設定 Material 的 color 屬性:
class _MainPageState extends State<MainPage> with SingleTickerProviderStateMixin {
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(length: 3, vsync: this);
}
@override
Widget build(BuildContext context) {
return Scaffold(
//使用 Material 改變 TabBar 背景色
bottomNavigationBar: Material(
color: Colors.blue,
child: TabBar (
...
),
),
body: TabBarView(
...
),
);
}
}
後續:上面 iPhone 手機底部黑線遮擋布局的問題解決辦法請檢視我的另一篇文章:解決 iPhone X 等劉海屏手機導航欄/底部黑線遮擋布局的方法