Unverified Commit d4c74858 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Make Decoration.padding non-nullable (#119581)

The default implementation returns EdgeInsets.zero, the ShapeDecoration subclass already makes it non-nullable, and there isn't any benefit to returning null as far as I can tell.
parent f6b0c6dd
...@@ -237,10 +237,10 @@ class Ink extends StatefulWidget { ...@@ -237,10 +237,10 @@ class Ink extends StatefulWidget {
final double? height; final double? height;
EdgeInsetsGeometry get _paddingIncludingDecoration { EdgeInsetsGeometry get _paddingIncludingDecoration {
if (decoration == null || decoration!.padding == null) { if (decoration == null) {
return padding ?? EdgeInsets.zero; return padding ?? EdgeInsets.zero;
} }
final EdgeInsetsGeometry decorationPadding = decoration!.padding!; final EdgeInsetsGeometry decorationPadding = decoration!.padding;
if (padding == null) { if (padding == null) {
return decorationPadding; return decorationPadding;
} }
......
...@@ -208,7 +208,7 @@ class BoxDecoration extends Decoration { ...@@ -208,7 +208,7 @@ class BoxDecoration extends Decoration {
final BoxShape shape; final BoxShape shape;
@override @override
EdgeInsetsGeometry? get padding => border?.dimensions; EdgeInsetsGeometry get padding => border?.dimensions ?? EdgeInsets.zero;
@override @override
Path getClipPath(Rect rect, TextDirection textDirection) { Path getClipPath(Rect rect, TextDirection textDirection) {
......
...@@ -59,7 +59,7 @@ abstract class Decoration with Diagnosticable { ...@@ -59,7 +59,7 @@ abstract class Decoration with Diagnosticable {
/// [EdgeInsetsGeometry.resolve] to obtain an absolute [EdgeInsets]. (For /// [EdgeInsetsGeometry.resolve] to obtain an absolute [EdgeInsets]. (For
/// example, [BorderDirectional] will return an [EdgeInsetsDirectional] for /// example, [BorderDirectional] will return an [EdgeInsetsDirectional] for
/// its [padding].) /// its [padding].)
EdgeInsetsGeometry? get padding => EdgeInsets.zero; EdgeInsetsGeometry get padding => EdgeInsets.zero;
/// Whether this decoration is complex enough to benefit from caching its painting. /// Whether this decoration is complex enough to benefit from caching its painting.
bool get isComplex => false; bool get isComplex => false;
......
...@@ -367,14 +367,14 @@ class Container extends StatelessWidget { ...@@ -367,14 +367,14 @@ class Container extends StatelessWidget {
final Clip clipBehavior; final Clip clipBehavior;
EdgeInsetsGeometry? get _paddingIncludingDecoration { EdgeInsetsGeometry? get _paddingIncludingDecoration {
if (decoration == null || decoration!.padding == null) { if (decoration == null) {
return padding; return padding;
} }
final EdgeInsetsGeometry? decorationPadding = decoration!.padding; final EdgeInsetsGeometry decorationPadding = decoration!.padding;
if (padding == null) { if (padding == null) {
return decorationPadding; return decorationPadding;
} }
return padding!.add(decorationPadding!); return padding!.add(decorationPadding);
} }
@override @override
......
...@@ -80,18 +80,24 @@ void main() { ...@@ -80,18 +80,24 @@ void main() {
' │ PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n' ' │ PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
' │ android)\n' ' │ android)\n'
' │\n' ' │\n'
' └─child: RenderLimitedBox#00000\n' ' └─child: RenderPadding#00000\n'
' │ parentData: <none> (can use size)\n' ' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n' ' │ size: Size(800.0, 600.0)\n'
' │ maxWidth: 0.0\n' ' │ padding: EdgeInsets.zero\n'
' │ maxHeight: 0.0\n'
' │\n' ' │\n'
' └─child: RenderConstrainedBox#00000\n' ' └─child: RenderLimitedBox#00000\n'
' parentData: <none> (can use size)\n' ' │ parentData: offset=Offset(0.0, 0.0) (can use size)\n'
' constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' size: Size(800.0, 600.0)\n' ' │ size: Size(800.0, 600.0)\n'
' additionalConstraints: BoxConstraints(biggest)\n', ' │ maxWidth: 0.0\n'
' │ maxHeight: 0.0\n'
' │\n'
' └─child: RenderConstrainedBox#00000\n'
' parentData: <none> (can use size)\n'
' constraints: BoxConstraints(w=800.0, h=600.0)\n'
' size: Size(800.0, 600.0)\n'
' additionalConstraints: BoxConstraints(biggest)\n',
), ),
); );
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment