Search code examples
flutterflutter-layoutshadow

Shadow blur efect in flutter


How can I create this shadow blur in the top and bottom of the Widget that appears to be on top of the list?

enter image description here


Solution

  • try to wrap your child with Stack and a mask:

    Stack(
      children: [
        //_yourWidget(),
                    Opacity(
                      opacity: 0.5,
                      child: Container(
                        width: 50.0,
                        height: 50.0,
                        decoration: const BoxDecoration(
                          gradient: LinearGradient(
                            begin: Alignment.topCenter,
                            end: Alignment.bottomCenter,
                            colors: <Color>[
                              Colors.black,
                              Colors.transparent,
                              Colors.transparent,
                              Colors.black,
                            ],
                            stops: [
                              0,
                              0.2,
                              0.8,
                              1,
                            ],
                          ),
                        ),
                      ),
                    ),
      ],
    )