const kBorderStyle2 = BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(20),
),
border: Border.all(color: Colors.greenAccent,),
);
Hi,
I've been learning flutter on my own and got stuck on this error.
I have a constants.dart file where I am saving all the styles for the app.
Whenever I try to add the color: Colors.greenAccent,
to the const, I get an error "const variable must be initialized with a constant value."
but then I change const to var and the problem goes away.
I also get the same error for the following code:
const kBorderStyleX = BoxDecoration(
color: Colors.greenAccent,
borderRadius: BorderRadius.circular(20),
);
This goes away when I change it to:
const kBorderStyle1 = BoxDecoration(
color: Colors.greenAccent,
borderRadius: BorderRadius.all(
Radius.circular(20),
),
);
Is there something I am missing with const? Any reason why I am getting the error?