当底部导航栏存在时,appbar 与通知栏重叠
Posted
技术标签:
【中文标题】当底部导航栏存在时,appbar 与通知栏重叠【英文标题】:appbar overlaps notification bar when bottom navigation bar is present 【发布时间】:2021-03-20 14:17:41 【问题描述】:当我通过底部导航导航到页面时,页面应用栏会被手机通知栏覆盖。
底部导航页面:
没有底部导航的同一页面:
***我需要我的应用栏看起来像底部导航的第二张图片。当我评论底部导航时,页面恢复正常。
import 'package:flutter/material.dart';
// import 'package:flutter_ecommerce_app/main.dart';
// import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter_ecommerce_app/screens/ShoppingCartPage(p).dart';
import 'package:flutter_ecommerce_app/screens/HomeScreen.dart';
import 'package:flutter_ecommerce_app/screens/profilePage.dart';
import 'package:flutter_ecommerce_app/screens/OurStores.dart';
import 'package:flutter_ecommerce_app/screens/NotificationsScreen.dart';
class BottomNavBarWidget extends StatefulWidget
@override
_BottomNavBarWidgetState createState() => new _BottomNavBarWidgetState();
class _BottomNavBarWidgetState extends State<BottomNavBarWidget>
int currentIndex = 2;
GlobalKey _bottomNavigationKey = GlobalKey();
final List<Widget> viewContainer = [
StoresNearMe(),
notifications(),
HomeScreen(),
CartScreen(),
ProfilePage()
];
@override
Widget build(BuildContext context)
// void onTap(int index)
// setState(()
// currentIndex = index;
// );
//
return SafeArea(
child: new Scaffold(
body: viewContainer[currentIndex],
bottomNavigationBar: CurvedNavigationBar(
key: _bottomNavigationKey,
index: currentIndex,
height: 45.0,
items: <Widget>[
Icon(Icons.menu_open),
Icon(Icons.notifications_active_rounded),
Icon(
Icons.home,
size: 35,
color: Colors.redAccent,
),
Icon(Icons.shopping_cart),
Icon(Icons.person),
],
color: Colors.grey[200],
buttonBackgroundColor: Colors.grey[400],
backgroundColor: Colors.white,
animationCurve: Curves.fastOutSlowIn,
animationDuration: Duration(milliseconds: 600),
onTap: (index)
setState(()
currentIndex = index;
print(currentIndex);
);
,
),
),
);
【问题讨论】:
【参考方案1】:您可以在身体周围使用填充。
Padding(
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top,),
child: child,
)
【讨论】:
以上是关于当底部导航栏存在时,appbar 与通知栏重叠的主要内容,如果未能解决你的问题,请参考以下文章
底部导航栏与 Jetpack Compose 中的屏幕内容重叠