在Flutter中使用'bottomNavigationBar'之后,'body'部分不可见

问题描述 投票:0回答:1

[每当我使用bottomNavigationBar:时,它都不会在屏幕上显示body:部分,但是当我移除bottomNavigationBar:时,它会显示body:这是code


class loginhomePage extends StatefulWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Home', textAlign: TextAlign.center),
        backgroundColor: Color(0xffd81b60),
      ),
      resizeToAvoidBottomPadding: false,

      body: ListView(children: <Widget>[
        Container(
          child:Column(
            children: <Widget>[
              Container(
                padding: EdgeInsets.fromLTRB(15.0, 40.0, 40.0, 25.0),
                child: Center(
                  child: Text(
                    'Home',
                    textAlign: TextAlign.center,
                  ),),), ], ),),
        SizedBox(height: 200.0),

      bottomNavigationBar: _getNavBar(context),

    );}}

_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,
                ])),
          ),
        ),
      ),

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}

没有错误显示只是身体在屏幕上不可见

请提出任何解决方案?

flutter dart flutter-layout flutter-appbar flutter-design
1个回答
0
投票
底部导航是脚手架构造函数Widget bottomNavigationBar的一部分,而不是主体,因此重构了代码,如下所示

Scaffold( appBar: AppBar( title: const Text('Home', textAlign: TextAlign.center), backgroundColor: Color(0xffd81b60), ), resizeToAvoidBottomPadding: false, body: ListView(children: <Widget>[ Container( child:Column( children: <Widget>[ Container( padding: EdgeInsets.fromLTRB(15.0, 40.0, 40.0, 25.0), child: Center( child: Text( 'Home', textAlign: TextAlign.center, ),),), ], ),), SizedBox(height: 200.0), ]),//listview bottomNavigationBar: _getNavBar(context), );//scaffold

© www.soinside.com 2019 - 2024. All rights reserved.