Fix nullability of ClipRRect.borderRadius (#125878)
The property was typed as nullable, but the code assumed its always non-null. This makes the property non-nullable as well. Also refactors CupertinoListSection, which was flagged by the analyzer when borderRadius became non-nullable (no functional change, just cleaning up existing code to avoid the warning).
This commit is contained in:
parent
f53335bff4
commit
4bf297ceb2
@ -402,8 +402,7 @@ class CupertinoListSection extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BorderRadius? childrenGroupBorderRadius;
|
Widget? decoratedChildrenGroup;
|
||||||
DecoratedBox? decoratedChildrenGroup;
|
|
||||||
if (children != null && children!.isNotEmpty) {
|
if (children != null && children!.isNotEmpty) {
|
||||||
// We construct childrenWithDividers as follows:
|
// We construct childrenWithDividers as follows:
|
||||||
// Insert a short divider between all rows.
|
// Insert a short divider between all rows.
|
||||||
@ -425,15 +424,11 @@ class CupertinoListSection extends StatelessWidget {
|
|||||||
childrenWithDividers.add(longDivider);
|
childrenWithDividers.add(longDivider);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
final BorderRadius childrenGroupBorderRadius = switch (type) {
|
||||||
case CupertinoListSectionType.insetGrouped:
|
CupertinoListSectionType.insetGrouped => _kDefaultInsetGroupedBorderRadius,
|
||||||
childrenGroupBorderRadius = _kDefaultInsetGroupedBorderRadius;
|
CupertinoListSectionType.base => BorderRadius.zero,
|
||||||
case CupertinoListSectionType.base:
|
};
|
||||||
childrenGroupBorderRadius = BorderRadius.zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Refactored the decorate children group in one place to avoid repeating it
|
|
||||||
// twice down bellow in the returned widget.
|
|
||||||
decoratedChildrenGroup = DecoratedBox(
|
decoratedChildrenGroup = DecoratedBox(
|
||||||
decoration: decoration ??
|
decoration: decoration ??
|
||||||
BoxDecoration(
|
BoxDecoration(
|
||||||
@ -445,6 +440,17 @@ class CupertinoListSection extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Column(children: childrenWithDividers),
|
child: Column(children: childrenWithDividers),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
decoratedChildrenGroup = Padding(
|
||||||
|
padding: margin,
|
||||||
|
child: clipBehavior == Clip.none
|
||||||
|
? decoratedChildrenGroup
|
||||||
|
: ClipRRect(
|
||||||
|
borderRadius: childrenGroupBorderRadius,
|
||||||
|
clipBehavior: clipBehavior,
|
||||||
|
child: decoratedChildrenGroup,
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DecoratedBox(
|
return DecoratedBox(
|
||||||
@ -464,17 +470,8 @@ class CupertinoListSection extends StatelessWidget {
|
|||||||
child: headerWidget,
|
child: headerWidget,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (children != null && children!.isNotEmpty)
|
if (decoratedChildrenGroup != null)
|
||||||
Padding(
|
decoratedChildrenGroup,
|
||||||
padding: margin,
|
|
||||||
child: clipBehavior == Clip.none
|
|
||||||
? decoratedChildrenGroup
|
|
||||||
: ClipRRect(
|
|
||||||
borderRadius: childrenGroupBorderRadius,
|
|
||||||
clipBehavior: clipBehavior,
|
|
||||||
child: decoratedChildrenGroup,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (footerWidget != null)
|
if (footerWidget != null)
|
||||||
Align(
|
Align(
|
||||||
alignment: AlignmentDirectional.centerStart,
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
@ -850,7 +850,7 @@ class ClipRRect extends SingleChildRenderObjectWidget {
|
|||||||
this.clipper,
|
this.clipper,
|
||||||
this.clipBehavior = Clip.antiAlias,
|
this.clipBehavior = Clip.antiAlias,
|
||||||
super.child,
|
super.child,
|
||||||
}) : assert(borderRadius != null || clipper != null);
|
});
|
||||||
|
|
||||||
/// The border radius of the rounded corners.
|
/// The border radius of the rounded corners.
|
||||||
///
|
///
|
||||||
@ -858,7 +858,7 @@ class ClipRRect extends SingleChildRenderObjectWidget {
|
|||||||
/// exceed width/height.
|
/// exceed width/height.
|
||||||
///
|
///
|
||||||
/// This value is ignored if [clipper] is non-null.
|
/// This value is ignored if [clipper] is non-null.
|
||||||
final BorderRadiusGeometry? borderRadius;
|
final BorderRadiusGeometry borderRadius;
|
||||||
|
|
||||||
/// If non-null, determines which clip to use.
|
/// If non-null, determines which clip to use.
|
||||||
final CustomClipper<RRect>? clipper;
|
final CustomClipper<RRect>? clipper;
|
||||||
@ -871,7 +871,7 @@ class ClipRRect extends SingleChildRenderObjectWidget {
|
|||||||
@override
|
@override
|
||||||
RenderClipRRect createRenderObject(BuildContext context) {
|
RenderClipRRect createRenderObject(BuildContext context) {
|
||||||
return RenderClipRRect(
|
return RenderClipRRect(
|
||||||
borderRadius: borderRadius!,
|
borderRadius: borderRadius,
|
||||||
clipper: clipper,
|
clipper: clipper,
|
||||||
clipBehavior: clipBehavior,
|
clipBehavior: clipBehavior,
|
||||||
textDirection: Directionality.maybeOf(context),
|
textDirection: Directionality.maybeOf(context),
|
||||||
@ -881,7 +881,7 @@ class ClipRRect extends SingleChildRenderObjectWidget {
|
|||||||
@override
|
@override
|
||||||
void updateRenderObject(BuildContext context, RenderClipRRect renderObject) {
|
void updateRenderObject(BuildContext context, RenderClipRRect renderObject) {
|
||||||
renderObject
|
renderObject
|
||||||
..borderRadius = borderRadius!
|
..borderRadius = borderRadius
|
||||||
..clipBehavior = clipBehavior
|
..clipBehavior = clipBehavior
|
||||||
..clipper = clipper
|
..clipper = clipper
|
||||||
..textDirection = Directionality.maybeOf(context);
|
..textDirection = Directionality.maybeOf(context);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user