简体   繁体   English

TabBar 固定容器阴影在 flutter 中垂直滚动时从 ListView 下降

[英]TabBar Fixed Container Shadow goes down of ListView while scrolling vertically in flutter

I want to add a bit shadow to my Container, which I have done using Material Widget or BoxShadow but in column at bottom of fixed container I have expanded Listview when I scroll up vertically container shadow goes down of Listview which I do not want I want Shadow to appear on top of ListView Items as we Scroll vertically, That's all please help me out我想给我的容器添加一点阴影,我已经使用Material WidgetBoxShadow完成了,但是在固定容器底部的列中,当我垂直向上滚动时,我扩展了 Listview 容器阴影从 Listview 下降,这是我不想要的当我们垂直滚动时,阴影会出现在 ListView 项目的顶部,这就是全部,请帮帮我

...Here is my code ...这是我的代码

Material(
              elevation: 2,
               child: Container(
                decoration: BoxDecoration(
                  color: Colors.white,
                  boxShadow: [
                    BoxShadow(
                      color: Colors.red,
                      blurRadius: 2,
                      spreadRadius: 2,
                      offset: Offset(0,2),


                    ),


                  ],
                ),
                height: SizeConfig.isLargeScreen ? 60.h : 105.h,
                width: double.infinity,
                child: !SizeConfig.isLargeScreen),),

Note : I have given elevation 3 to my Listview card as well, Please let me know what i can do to make this container shadow go above Listview while Scrolling Vertically注意:我也为我的 Listview 卡提供了海拔 3,请让我知道我可以做些什么来使这个容器在垂直滚动时在 Listview 上方阴影 go

  1. I guess this can be solved by using padding widget, know more about the padding widget in ( https://youtu.be/oD5RtLhhubg ).我想这可以通过使用填充小部件来解决,了解更多关于( https://youtu.be/oD5RtLhhubg )中的填充小部件。

  2. Another way to handle the issue adding a listView with separator, divider.处理添加带有分隔符、分隔符的 listView 问题的另一种方法。

  3. Still the problem continues check with margin of the container.仍然问题继续检查容器的边缘。

  4. Finally on top of all since this is about container shadow you can try with the offset value in boxshadow property.最后,由于这是关于容器阴影的,您可以尝试使用 boxshadow 属性中的偏移值。

  5. share with us, which method helps you to solve the issue or how did you solved the issue by trying something different.与我们分享,哪种方法可以帮助您解决问题,或者您是如何通过尝试不同的方法来解决问题的。

You have two ways to solve this issue the first one is to wrap your Material widget with Padding widget like this:您有两种方法可以解决此问题,第一种是使用Padding 小部件包装您的Material 小部件,如下所示:

Padding(
    Material(
          elevation: 2,
           child: Container(
            decoration: BoxDecoration(
              color: Colors.white,
              boxShadow: [
                BoxShadow(
                  color: Colors.red,
                  blurRadius: 2,
                  spreadRadius: 2,
                  offset: Offset(0,2),


                ),


              ],
            ),
            height: SizeConfig.isLargeScreen ? 60.h : 105.h,
            width: double.infinity,
            child: !SizeConfig.isLargeScreen),),),

or simply add SizedBox(height: 20,), under the Material widget it will make some space between the Material widget and the ListView then it will solve your issue或者简单地添加SizedBox(height: 20,),Material 小部件下,它将在Material 小部件ListView之间留出一些空间,然后它将解决您的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM