When scrolling vertically in a Flutter app, the TabBar Fixed Container Shadow descends beneath the ListView

I have successfully added a shadow to my Container using the Material Widget and BoxShadow. However, I am facing an issue with the shadow position when I expand a ListView at the bottom of the fixed container. As I scroll up vertically, the container shadow goes down behind the ListView items, which is not the desired behavior. I want the shadow to appear on top of the ListView items as I scroll vertically. Can someone please assist me with this?

Below is the snippet of 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 also given elevation 3 to my ListView card. How can I make sure that the container shadow stays above the ListView while scrolling vertically? Any help would be greatly appreciated.

Answer №1

  1. To resolve this issue, consider utilizing the padding widget. Learn more about the padding widget at ( https://youtu.be/oD5RtLhhubg ).

  2. Another approach to addressing the problem is by incorporating a listView with separators and dividers.

  3. If the problem persists, try adjusting the margin of the container.

  4. Additionally, for container shadow-related issues, experiment with the offset value in the boxshadow property.

  5. We would love to hear from you! Share which method helped you solve the problem or if you found success through a different strategy.

Answer №2

If you're facing this problem, there are two effective solutions you can try out. The first method involves wrapping your Material widget with a Padding widget like shown below:

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

Alternatively, you can simply insert SizedBox(height: 20,), right after the Material widget. This will add some space between the Material widget and the ListView, effectively resolving the issue.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Words hovering in a section next to a captivating picture

I am looking to achieve a specific arrangement: I want two different texts (in block format) to float or display inline next to an image, all within a div element. Despite trying various display settings (such as block and inline for text), I have not be ...

What is the best way to append a single class while also ensuring any previously added classes are removed?

How can I apply the selected class and remove any previously selected classes? <html> <select name="Button-Style" id="Button-Style" style="width:100%;"> <option value="Sun-Flower">Sun Flower</option> <option value ...

Place images within a card container using Bootstrap 4

I'm currently working with Bootstrap 4 and I am utilizing a card div. The card uses display flex and I am having trouble floating images within it, possibly because the card is configured to only allow one image. How can I successfully float multiple ...

A step-by-step guide to customizing MUI CSS within a React component that incorporates MUI elements

Here is a custom Reactjs component I created and used in various components: function CustomSearchBox({ handle, placeholder, inputType, ...props}) { return ( <Box sx={{ display: 'flex', ali ...

JQueryUI dialog is falling short in terms of maximum width

I am experiencing an issue with a jqueryui dialog that I have defined with a maxWidth setting. $("#myDialog").dialog({ autoOpen: false, width: 'auto', maxWidth: 1000, height: 'auto', position: [2 ...

Hover shows no response

I'm having trouble with my hover effect. I want an element to only be visible when hovered over, but it's not working as expected. I've considered replacing the i tag with an a, and have also tried using both display: none and display: bloc ...

How can I adjust the view port height to display the footer on the screen without the need for a scroll

Exploring some css techniques. I'm attempting to display the footer on the page without requiring a scrollbar. My approach involves subtracting the footer's height from the content wrapper div. Unfortunately, this method doesn't seem to be e ...

The CSS hover animation functions smoothly in CodeSandbox using React, but encounters issues when integrated into a Next.js project

Challenge Here, in my codesandbox project, I created a hover animation for a div element. When I implemented the code on a li element in my next.js project, the hover effect is triggered not on hover, but on click. Additionally, the element remains in the ...

Creating an Art Deco inspired border using CSS

I am interested in creating a border effect using only CSS. Here is an image of the effect I am looking to achieve: https://i.sstatic.net/cKWXZm.jpg I would like to achieve this effect without adding additional div elements. Any suggestions or tips on how ...

Utilizing Bootstrap for Content Width as Opposed to Full Screen Width

I am currently utilizing Bootstrap 4, but I prefer not to rely on the screen width for my layout. Instead, I want it to adapt based on the width of a specific container. Despite my efforts in searching for a solution, I have been unable to find the necess ...

Responsive Text and Alignment in the Latest Bootstrap 5

My goal is to center my div element while keeping the text aligned to the left. Here's the code I have: <div class="container"> <div class="row"> <div class="col"> <h1>< ...

Tips for aligning the navbar logo at the center in Bootstrap 4 when there are navigation links positioned below

I'm having trouble centering the navbar logo with the nav-links below it. I've checked various posts on this issue, but they all seem to be using older versions of bootstrap. I am currently working with bootstrap 4.0. Specifically, I would like ...

The Dilemma of Hover Effects in Internet Explorer 7

How can I make an image display another image with 4 absolutely positioned links when hovered over? The code currently works in Chrome, Firefox, Safari, and all versions of IE except IE7. Any suggestions for IE7 compatibility? For reference, here is the J ...

The background color and image failed to cover the entire CSS box model

Hi there, I've been struggling with this issue and can't seem to figure out why. No matter what adjustments I make, the background color and image just won't fill the entire CSS box model. If you want to take a look at what I'm talking ...

Problems with select box rendering in Internet Explorer with Materialize CSS

When using materializecss select box in Internet Explorer 9 or higher, scrolling with the mouse button is not working. You must click on the scroll bar inside the select box for it to scroll. This issue does not occur in other browsers. I have attached a s ...

I'm looking to showcase the list in a navigation bar by clicking on the hamburger menu. I want to include the 'home' and 'about' text specifically

Having trouble implementing the hamburger menu functionality in my HTML/CSS project. When clicked on a shrunken screen, I want the 'Home' and 'About' text in the nav to appear stacked on top of each other. JS is causing me some difficul ...

Altering the innerHTML of a <p> tag with a smooth transition

I am a beginner in the world of web design. I am currently working on a project where I need to continuously change the text inside a <p> element with a transition effect similar to a slideshow. Below is the code I have so far: <p id="qu">S ...

Manipulating CSS rules using JavaScript/jQuery

My goal is to create a function that generates a grid based on table data. While the function itself seems to be working, I am encountering an issue where the classes applied are not resulting in any style changes. Below is a snippet of my function: $(doc ...

Can you remind me of the specific CSS class used for Internet Explorer in Twitter Bootstrap?

Currently utilizing Twitter Bootstrap and curious if there is a specific CSS class to designate IE browsers within the BODY or HTML tags. Interested in writing CSS specifically for all IE browsers. Aware that Bootstrap offers some CSS classes for IE brows ...

Having trouble getting a DIV to appear on top of another DIV containing an image

I need help with positioning an "InfoBox" above the main header image on my website. Despite trying z-indexes and adjusting position, I can't seem to get it right. If anyone has any suggestions, please share. Thank you! For reference, here is the HTM ...