每当我使用 bottomNavigationBar:时,它不会在屏幕上显示主体:部分,但是当我删除 bottomNavigationBar:时,它将显示主体:
这是代码
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Home', textAlign: TextAlign.center),
actions: <Widget>[],
backgroundColor: Color(0xffd81b60),
),
bottomNavigationBar: _getNavBar(context),
body: ListView(children: <Widget>[
SizedBox(height: 300.0),
Container(
height: 50,
width: 10,
child: Center(
child: RaisedButton(
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => mealwisePage()));
},
color: Colors.pink,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Meal Wise',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20, color: Colors.white),
),), ), ), ), ]),);}
_getNavBar(context) {
return Stack(
children: <Widget>[
Positioned(
bottom: 0,
child: ClipPath(
clipper: NavBarClipper(),
child: Container(
height: 50,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.pink,
Colors.pink.shade800,
])), ),),),],);}
有什么解决办法吗?
最佳答案
我发现这是因为使用了堆栈,它与主体重叠,所以我更改了它
从:
return Stack(
children: <Widget>[
Positioned(
bottom: 0,
child: ClipPath(
clipper: NavBarClipper(),
child: Container(),),)],)
至
return Container(
height: 90,
child: Stack(
alignment: Alignment.bottomCenter,
children: <Widget>[
Positioned(
bottom: 0,
child: ClipPath(
clipper: NavBarClipper(),
child: Container(),),),],),)
关于flutter - 在Flutter中使用 'body'后, ' bottomNavigationBar'部分不可见,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59787007/