flutter 当底部导航栏存在时,appbar与通知栏重叠

cbeh67ev  于 2023-11-21  发布在  Flutter
关注(0)|答案(2)|浏览(184)

当我通过底部导航导航到页面时,页面应用栏会被手机通知栏覆盖。

带底部导航的页面:


的数据
没有底部导航的页面:


  • 我需要我的应用程序栏看起来像底部导航的第二张图片。当我在底部导航上评论时,页面会恢复正常。
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);
                });
              },
            ),
          ),
        );
      }
    }

字符串

vpfxa7rd

vpfxa7rd1#

你可以在身体周围使用填充物。

Padding(
  padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top,),
  child: child,
)

字符串

c8ib6hqw

c8ib6hqw2#

它想在状态栏上播放你的应用样式,但是SafeArea小部件阻止了它。

相关问题