This is Flutter series, if you not familiar with Flutter development here is the post for you.
Encounter and treat null is a should have in development cycle. We know how to deal with null around class, objects and functions too. So how about widget and properties.
I have customized a Material button (I will pull that stuff in the next post) which accepting different type of borders, StadiumBorder() like stuff. By default I want to set StadiumBorder, if user not passing any values. Possibly fire an error on default value for shape.
So how do we check null ?
Here is the solution
shape:newshape!=null ? newshape: const StadiumBorder(),
I check for the new value for shape , if it fails I use a default one. Quiet simple , isn’t it.