Is there any way at all we can get the parent widgets borderRadius property? If it makes things any clearer, this is the context of asking the question: I'm authoring the glass package on pub.dev/packages/glass. It allows you to convert any widget to a glass version by calling an extension .asGlass() method on it, which involved a ClipRRect widget. However, since I don't know if the widget on which asGlass is called has a borderRadius, sometimes the glass effect extends over the borders of the parent widget (i.e. the widget has rounded borders, while the glass effect has rectangular borders). So is there any way I can get the borderRadius or any property at all from the calling widget without the user having to pass it explicitly?
Passing the value of a borderRadius is a cleaner approach and should be followed.
You can make an optional radius argument with default value of 0. A rectangle is rendered unless a borderRadius is specified.
asGlass(BorderRadiusGeometry borderRadius = BorderRadius.zero){...}
Now whenever your parent has a border radius just pass it in:
var _borderRadius = BorderRadius.circular(10);
Card(
...,
borderRadius: _borderRadius,
).asGlass(_borderRadius);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With