winnyboy5
winnyboy5

Reputation: 1516

The argument type 'BoxShadow' can't be assigned to the parameter type 'List<BoxShadow>'

I am trying to build a custom list Item in flutter. When I am trying to assign box radius to the list item I am facing the below syntax error:

**The argument type 'BoxShadow' can't be assigned to the parameter type 'List<BoxShadow>'.**

It seems like I couldn't assign box shadow to the list. I am new to flutter is there a way to add custom box shadow to a list item of an AnimatedList(). I have provided the code below:

Widget _buildItem(UserModel user, [int index]) {
return Container(
  padding: EdgeInsets.all(8.0),
  margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
  decoration: BoxDecoration(
    color: Colors.grey[50],
    borderRadius: BorderRadius.all(Radius.circular(5.0)),
    boxShadow: BoxShadow(
      blurRadius: 5.0
    )
  ),
  child: Row(
    children: <Widget>[
      InkWell(
        child: CircleAvatar(
          radius: 30.0,
          backgroundImage: NetworkImage(user.photo, scale: 64.0),
        ),
        onLongPress: index != null ? () => deleteUser(index) : null,
      )
    ],
  ),
);

}

Upvotes: 1

Views: 4970

Answers (1)

Ravinder Kumar
Ravinder Kumar

Reputation: 7990

Because boxShadow must contain list [],

Your fix is,

...
         boxShadow: [
                  BoxShadow(
                    color: Colors.amber.shade100,
                    blurRadius: 15.0,
                    // has the effect of softening the shadow
//                    spreadRadius: 2.0,
                    // has the effect of extending the shadow
                    offset: Offset(
                      1.0, // horizontal, move right 10
                      5.0, // vertical, move down 10
                    ),
                  )
                ],

Upvotes: 9

Related Questions