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.
This commit is contained in:
@@ -237,10 +237,10 @@ class Ink extends StatefulWidget {
|
||||
final double? height;
|
||||
|
||||
EdgeInsetsGeometry get _paddingIncludingDecoration {
|
||||
if (decoration == null || decoration!.padding == null) {
|
||||
if (decoration == null) {
|
||||
return padding ?? EdgeInsets.zero;
|
||||
}
|
||||
final EdgeInsetsGeometry decorationPadding = decoration!.padding!;
|
||||
final EdgeInsetsGeometry decorationPadding = decoration!.padding;
|
||||
if (padding == null) {
|
||||
return decorationPadding;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ class BoxDecoration extends Decoration {
|
||||
final BoxShape shape;
|
||||
|
||||
@override
|
||||
EdgeInsetsGeometry? get padding => border?.dimensions;
|
||||
EdgeInsetsGeometry get padding => border?.dimensions ?? EdgeInsets.zero;
|
||||
|
||||
@override
|
||||
Path getClipPath(Rect rect, TextDirection textDirection) {
|
||||
|
||||
@@ -59,7 +59,7 @@ abstract class Decoration with Diagnosticable {
|
||||
/// [EdgeInsetsGeometry.resolve] to obtain an absolute [EdgeInsets]. (For
|
||||
/// example, [BorderDirectional] will return an [EdgeInsetsDirectional] for
|
||||
/// its [padding].)
|
||||
EdgeInsetsGeometry? get padding => EdgeInsets.zero;
|
||||
EdgeInsetsGeometry get padding => EdgeInsets.zero;
|
||||
|
||||
/// Whether this decoration is complex enough to benefit from caching its painting.
|
||||
bool get isComplex => false;
|
||||
|
||||
@@ -367,14 +367,14 @@ class Container extends StatelessWidget {
|
||||
final Clip clipBehavior;
|
||||
|
||||
EdgeInsetsGeometry? get _paddingIncludingDecoration {
|
||||
if (decoration == null || decoration!.padding == null) {
|
||||
if (decoration == null) {
|
||||
return padding;
|
||||
}
|
||||
final EdgeInsetsGeometry? decorationPadding = decoration!.padding;
|
||||
final EdgeInsetsGeometry decorationPadding = decoration!.padding;
|
||||
if (padding == null) {
|
||||
return decorationPadding;
|
||||
}
|
||||
return padding!.add(decorationPadding!);
|
||||
return padding!.add(decorationPadding);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -80,18 +80,24 @@ void main() {
|
||||
' │ PlatformAssetBundle#00000(), devicePixelRatio: 3.0, platform:\n'
|
||||
' │ android)\n'
|
||||
' │\n'
|
||||
' └─child: RenderLimitedBox#00000\n'
|
||||
' └─child: RenderPadding#00000\n'
|
||||
' │ parentData: <none> (can use size)\n'
|
||||
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
|
||||
' │ size: Size(800.0, 600.0)\n'
|
||||
' │ maxWidth: 0.0\n'
|
||||
' │ maxHeight: 0.0\n'
|
||||
' │ padding: EdgeInsets.zero\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',
|
||||
' └─child: RenderLimitedBox#00000\n'
|
||||
' │ parentData: offset=Offset(0.0, 0.0) (can use size)\n'
|
||||
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
|
||||
' │ size: Size(800.0, 600.0)\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',
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user