【发布时间】:2019-12-20 05:05:21
【问题描述】:
我想要一个像这样的弯曲底栏,后面有阴影:
我尝试创建类似的东西,但是当我将 bottomBar 放在 Scaffold 上时,当我向下滚动时它会切割身体。如果我尝试将 Scaffold 主体部分的边缘变圆,那么我将没有 Shadow。有谁知道这是怎么做到的吗 ?提前致谢
【问题讨论】:
-
请尝试使用屏幕截图和代码来解释您期望得到什么以及已经得到什么,以便有人可以帮助您。
我想要一个像这样的弯曲底栏,后面有阴影:
我尝试创建类似的东西,但是当我将 bottomBar 放在 Scaffold 上时,当我向下滚动时它会切割身体。如果我尝试将 Scaffold 主体部分的边缘变圆,那么我将没有 Shadow。有谁知道这是怎么做到的吗 ?提前致谢
【问题讨论】:
将其放入堆栈中。不要直接将底部导航栏添加到脚手架。
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Some Text'),
),
body: Stack(
children: <Widget>[
bodyContent,
Positioned(
left: 0,
right: 0,
bottom: 0,
child: bottomNavigationBar,
),
],
),
);
}
Widget get bodyContent {
return Container(color: Colors.red);
}
Widget get bottomNavigationBar {
return ClipRRect(
borderRadius: BorderRadius.only(
topRight: Radius.circular(40),
topLeft: Radius.circular(40),
),
child: BottomNavigationBar(
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('1')),
BottomNavigationBarItem(icon: Icon(Icons.usb), title: Text('2')),
BottomNavigationBarItem(
icon: Icon(Icons.assignment_ind), title: Text('3')),
BottomNavigationBarItem(
icon: Icon(Icons.multiline_chart), title: Text('4')),
],
unselectedItemColor: Colors.grey,
selectedItemColor: Colors.black,
showUnselectedLabels: true,
),
);
}
}
【讨论】: