【问题标题】:Force The Top Part Of The Screen's Widget to keep showing when Scrolling the ListviewItmes down, Flutter向下滚动 ListviewItem 时,强制屏幕小部件的顶部继续显示,颤振
【发布时间】:2021-01-31 09:09:06
【问题描述】:

请问当我向下滚动列表视图时如何强制屏幕顶部不消失? 正如你在这张照片中看到的那样

当我向下滚动 ListView 时,包含播放器小部件的顶部将消失

那么当我向下滚动 Listview 时,我该如何强制 Top Widgets 继续显示

Scaffold(
        body: Container(
          child: ListView(
            shrinkWrap: true,
            children: <Widget>[
              Center(
                child: Container(
                  width: 200.0,
                  height: 150.0,
                  child: Stack(
                    children: <Widget>[
                      Container(
                        decoration: BoxDecoration(
                            color:Color(0xff193451).withOpacity(.5),
                            shape: BoxShape.circle),
                        child: Padding(
                          padding: const EdgeInsets.all(.0),
                          child: _buildRadialSeekBar(),
                        ),
                      ),
                      Center(
                        child: Container(
                          width: 150.0,
                          height: 150.0,
                          child: Padding(
                            padding: const EdgeInsets.all(5.0),
                            child: ClipOval(
                              clipper: MClipper(),
                              child: Image.asset(
                                "assets/justine.jpg",
                                fit: BoxFit.cover,
                              ),
                            ),
                          ),
                        ),
                      )
                    ],
                  ),
                ),
              ),
              Container(
                // color: Colors.blue,
                width: 350.0,
                height: 100.0,
                child: Stack(
                  children: <Widget>[
                    Center(
                      child: Container(
                        height: 65.0,
                        width: 290.0,
                        decoration: BoxDecoration(
                            border: Border.all(
                                color: Color(0xff193451), width: 3.0),
                            borderRadius: BorderRadius.circular(40.0)),
                        child: Padding(
                          padding: const EdgeInsets.symmetric(horizontal: 25.0),
                          child: Row(
                            children: <Widget>[
                              Icon(Icons.fast_rewind,
                                  size: 55.0, color: Color(0xff193451)),
                              Expanded(
                                child: Container(),
                              ),
                              Icon(Icons.fast_forward,
                                  size: 55.0, color: Color(0xff193451))
                            ],
                          ),
                        ),
                      ),
                    ),
                    Align(
                      alignment: Alignment.center,
                      child: Container(
                        width: 92.0,
                        height: 92.0,
                        decoration: BoxDecoration(
                            color: Color(0xff193451), shape: BoxShape.circle),
                        child: IconButton(
                          icon: Icon(
                            Icons.play_arrow,
                            size: 45.0,
                            color: Colors.white,
                          ),
                          onPressed: () {},
                        ),
                      ),
                    )
                  ],
                ),
              ),
          ListView(
            shrinkWrap: true,
            physics: ClampingScrollPhysics(),
            children: [
              if(LocalUrl == "http://local") Container(child: ParseLocall(),),
              if(LocalUrl == "http://music") Container(child: ParseMusicc(),),
              if(LocalUrl == "http://talk") Container(child: ParseTalkk(),),
              if(LocalUrl == "http://sports") Container(child: ParseSportss(),),
              if(LocalUrl == "http://id=r0") Container(child: ParseByLocationn(),),
              if(LocalUrl == "http://lang") Container(child: ParseLanguagess(),),
              if(LocalUrl == "http://podcast") Container(child: ParseProdcastss(),),
            ],
          ),
            ],
          ),
        ));

提前致谢

【问题讨论】:

    标签: flutter listview dart


    【解决方案1】:

    您可以将Justin 部分与ListView 分开,并用Column 包装它们。代码还需要一些修复,但会是这样:

     body: Container(
              // Here is the Column!
              child: Column(
                children: [
                  // And here is the top part!
                  Center(
                    child: Container(
                      width: 200.0,
                      height: 150.0,
                      child: Stack(
                        children: <Widget>[
                          Container(
                            decoration: BoxDecoration(
                                color:Color(0xff193451).withOpacity(.5),
                                shape: BoxShape.circle),
                            child: Padding(
                              padding: const EdgeInsets.all(.0),
                              child: _buildRadialSeekBar(),
                            ),
                          ),
                          Center(
                            child: Container(
                              width: 150.0,
                              height: 150.0,
                              child: Padding(
                                padding: const EdgeInsets.all(5.0),
                                child: ClipOval(
                                  clipper: MClipper(),
                                  child: Image.asset(
                                    "assets/justine.jpg",
                                    fit: BoxFit.cover,
                                  ),
                                ),
                              ),
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                  
                  ListView(
                    shrinkWrap: true,
                    children: <Widget>[
                      Container(
                        // color: Colors.blue,
                        width: 350.0,
                        height: 100.0,
                        child: Stack(
                          children: <Widget>[
                            Center(
                              child: Container(
                                height: 65.0,
                                width: 290.0,
                                decoration: BoxDecoration(
                                    border: Border.all(
                                        color: Color(0xff193451), width: 3.0),
                                    borderRadius: BorderRadius.circular(40.0)),
                                child: Padding(
                                  padding: const EdgeInsets.symmetric(horizontal: 25.0),
                                  child: Row(
                                    children: <Widget>[
                                      Icon(Icons.fast_rewind,
                                          size: 55.0, color: Color(0xff193451)),
                                      Expanded(
                                        child: Container(),
                                      ),
                                      Icon(Icons.fast_forward,
                                          size: 55.0, color: Color(0xff193451))
                                    ],
                                  ),
                                ),
                              ),
                            ),
                            Align(
                              alignment: Alignment.center,
                              child: Container(
                                width: 92.0,
                                height: 92.0,
                                decoration: BoxDecoration(
                                    color: Color(0xff193451), shape: BoxShape.circle),
                                child: IconButton(
                                  icon: Icon(
                                    Icons.play_arrow,
                                    size: 45.0,
                                    color: Colors.white,
                                  ),
                                  onPressed: () {},
                                ),
                              ),
                            )
                          ],
                        ),
                      ),
                  ListView(
                    shrinkWrap: true,
                    physics: ClampingScrollPhysics(),
                    children: [
                      if(LocalUrl == "http://local") Container(child: ParseLocall(),),
                      if(LocalUrl == "http://music") Container(child: ParseMusicc(),),
                      if(LocalUrl == "http://talk") Container(child: ParseTalkk(),),
                      if(LocalUrl == "http://sports") Container(child: ParseSportss(),),
                      if(LocalUrl == "http://id=r0") Container(child: ParseByLocationn(),),
                      if(LocalUrl == "http://lang") Container(child: ParseLanguagess(),),
                      if(LocalUrl == "http://podcast") Container(child: ParseProdcastss(),),
                    ],
                  ),
                    ],
                  ),
                ],
              ),
            ));
    
    

    【讨论】:

    • 感谢您的帮助,我得到了已知错误 A RenderFlex 在底部溢出了 425 像素来修复它,我应该使用 SingleChildScrollView 小部件或再次使用列表视图,如果我使用 SingleChildScrollView 则相同问题会发生 - 如果我为顶部小部件使用另一个列表视图,顶部小部件也会消失,同样的情况。再次感谢您的帮助
    • 你应该避免使用像这样的高度属性:height: 100.0, height: 92.0, height: 65.0,
    • 非常感谢,你说得对,谢谢你教我。
    猜你喜欢
    • 2019-05-23
    • 2020-11-08
    • 1970-01-01
    • 2018-10-24
    • 1970-01-01
    • 1970-01-01
    • 2021-06-09
    • 2019-08-03
    • 1970-01-01
    相关资源
    最近更新 更多