How can I add shadow to the widget in flutter?

前端 未结 8 1528
余生分开走
余生分开走 2020-12-04 09:07

How can I add shadow to the widget like in the picture below?

This is my current widget code.

8条回答
  •  生来不讨喜
    2020-12-04 09:38

    Use Material with shadowColor inside Container like this:

    Container(
      decoration: BoxDecoration(
          borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(10),
              bottomRight: Radius.circular(10)),
          boxShadow: [
            BoxShadow(
                color: Color(0xffA22447).withOpacity(.05),
                offset: Offset(0, 0),
                blurRadius: 20,
                spreadRadius: 3)
          ]),
      child: Material(
        borderRadius: BorderRadius.only(
            bottomLeft: Radius.circular(10),
            bottomRight: Radius.circular(10)),
        elevation: 5,
        shadowColor: Color(0xffA22447).withOpacity(.05),
        color: Color(0xFFF7F7F7),
        child: SizedBox(
          height: MediaQuery.of(context).size.height / 3,
        ),
      ),
    )
    

提交回复
热议问题