Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BoxDecoration widget missing padding property

Tags:

flutter

dart

The BoxDecoration class docs show that this widget has a padding property.

Yet when I use it with this property, I get that: The named parameter 'padding' isn't defined.

I thought maybe my version of flutter was out of date, but I'm using v1.7.8+hotfix.4, which is the most recent (as of August 7th 2019), so I'm not sure how to fix this error.

My code looks something like:

DrawerHeader(
  ...
  decoration: BoxDecoration(... padding: EdgeInsets.all(4.0))
)
like image 959
AbsoluteSpace Avatar asked Nov 17 '25 03:11

AbsoluteSpace


2 Answers

I saw that the answer above is incomplete, so here is my full example answer hope it helps. decoration: BoxDecoration() have padding property because it is a class property

DrawerHeader(
          decoration: BoxDecoration(color: Colors.white),
          padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
          child: ...
),
like image 160
CookieThief Avatar answered Nov 21 '25 08:11

CookieThief


As @pskink mentioned in the comments, the BoxDecoration constructor doesn't have a padding parameter, so it's determined by padding = border?.dimensions instead.

like image 32
AbsoluteSpace Avatar answered Nov 21 '25 10:11

AbsoluteSpace