Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

spreadRadius value as parameter in flutter

I am making a global boxShadow list that I want to use in the whole app.
I am trying to pass spreadRadius value(i.e. 5 in the code below) as a parameter to make it dynamic in my custom list of BoxShadow.

Here is the code:

List<BoxShadow> outerShadow = [
  BoxShadow(
    color: Colors.grey.withOpacity(0.4),
    spreadRadius: 5,
    blurRadius: 7,
    offset: const Offset(0, 3),
  )
];

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You need to create a method if you wish to pass some data as a parameter.

List<BoxShadow> outerShadow(double spreadRadiusVal){
return [
  BoxShadow(
    color: Colors.grey.withOpacity(0.4),
    spreadRadius: spreadRadiusVal,
    blurRadius: 7,
    offset: const Offset(0, 3),
  )
];
}

And use it like

boxShadow : outerShadow(5.0),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading