The 'body' part is not visible after using ' bottomNavigationBar' in Flutter

2,051

I fount that it is because of using Stack it overlaps with body so i changed it from:

return Stack(
    children: <Widget>[
      Positioned(
        bottom: 0,
        child: ClipPath(
          clipper: NavBarClipper(),
          child: Container(),),)],)

To

return Container(
      height: 90,
      child: Stack(
        alignment: Alignment.bottomCenter,
    children: <Widget>[
      Positioned(
        bottom: 0,
        child: ClipPath(
          clipper: NavBarClipper(),
          child: Container(),),),],),)
Share:
2,051
Sanwal Ijaz
Author by

Sanwal Ijaz

Updated on November 28, 2022

Comments

  • Sanwal Ijaz
    Sanwal Ijaz over 1 year

    Whenever i use the bottomNavigationBar: it dose not show the body: part on screen but when i remove the bottomNavigationBar: then it shows the body: Here is the code

    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,
                    ])), ),),),],);}
    
    

    No error is showing just body is invisible on the screen

    Any Solution Please?

  • Sanwal Ijaz
    Sanwal Ijaz over 4 years
    The code is as it is as you are saying,Actually while posting the question stackoverflow suggest me to reduce the code so while reducing the code it becomes like this sorry for that now i have updated the code in question.
  • Sanwal Ijaz
    Sanwal Ijaz over 4 years
    did'nt work for me, actually this is not the complete code and i am unable to post complete code in the question.here is complete code of bottom navigation bar that i used: github.com/stevendz/customappbar_yt/blob/master/lib/main.dar‌​t
  • Sanwal Ijaz
    Sanwal Ijaz over 4 years
    i identified , it is because of Stack Widget so i used it in a container with height:100 now everything is visible above the container,so please tell me if you know any other good approach.