* opt: linter

* tweaks

* opt: TopImage

* update

* remove repaintBoundary [skip ci]

---------

Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
My-Responsitories
2026-03-12 15:45:18 +08:00
committed by GitHub
parent 99128b2641
commit 6cda3a1880
25 changed files with 237 additions and 323 deletions

View File

@@ -20,20 +20,16 @@ class DisabledIcon extends SingleChildRenderObjectWidget {
final StrokeCap strokeCap;
final double lineLengthScale;
Icon? get _icon => child is Icon ? child as Icon : null;
@override
RenderObject createRenderObject(BuildContext context) {
late final iconTheme = IconTheme.of(context);
final icon = _icon;
return RenderMaskedIcon(
disable: disable,
iconSize:
iconSize ??
(child is Icon ? (child as Icon).size : null) ??
iconTheme.size ??
24.0,
color:
color ??
(child is Icon ? (child as Icon).color : null) ??
iconTheme.color!,
iconSize: iconSize ?? icon?.size ?? iconTheme.size ?? 24.0,
color: color ?? icon?.color ?? iconTheme.color!,
strokeCap: strokeCap,
lineLengthScale: lineLengthScale,
);
@@ -42,17 +38,11 @@ class DisabledIcon extends SingleChildRenderObjectWidget {
@override
void updateRenderObject(BuildContext context, RenderMaskedIcon renderObject) {
late final iconTheme = IconTheme.of(context);
final icon = _icon;
renderObject
..disable = disable
..iconSize =
iconSize ??
(child is Icon ? (child as Icon).size : null) ??
iconTheme.size ??
24.0
..color =
color ??
(child is Icon ? (child as Icon).color : null) ??
iconTheme.color!
..iconSize = iconSize ?? icon?.size ?? iconTheme.size ?? 24.0
..color = color ?? icon?.color ?? iconTheme.color!
..strokeCap = strokeCap
..lineLengthScale = lineLengthScale;
}

View File

@@ -43,42 +43,3 @@ class NoRenderLayoutBox extends RenderProxyBox {
@override
void paint(PaintingContext context, Offset offset) {}
}
class LayoutSizeWidget extends SingleChildRenderObjectWidget {
const LayoutSizeWidget({
super.key,
super.child,
required this.onPerformLayout,
});
final LayoutCallback onPerformLayout;
@override
RenderObject createRenderObject(BuildContext context) =>
RenderLayoutBox(onPerformLayout: onPerformLayout);
@override
void updateRenderObject(
BuildContext context,
RenderLayoutBox renderObject,
) {
super.updateRenderObject(context, renderObject);
renderObject.onPerformLayout = onPerformLayout;
}
}
class RenderLayoutBox extends RenderProxyBox {
RenderLayoutBox({required this.onPerformLayout});
LayoutCallback onPerformLayout;
Size? _size;
@override
void performLayout() {
super.performLayout();
if (_size != size) {
onPerformLayout(_size = size);
}
}
}

View File

@@ -96,7 +96,6 @@ class RenderSliverFixedWrap extends RenderSliverMultiBoxAdaptor {
set runSpacing(double value) {
if (_runSpacing == value) return;
_runSpacing = value;
markRowsDirty();
markNeedsLayout();
}
@@ -168,20 +167,20 @@ class RenderSliverFixedWrap extends RenderSliverMultiBoxAdaptor {
}
}
bool _buildNextRow(int start, BoxConstraints childConstraints) {
bool _buildNextRow(int start, BoxConstraints constraints) {
final int childCount = childManager.childCount;
if (start >= childCount) {
return false;
}
final crossAxisExtent = constraints.crossAxisExtent;
final crossAxisExtent = this.constraints.crossAxisExtent;
final List<double> widths = [];
int idx = start;
RenderBox? child;
for (var totalWidth = -_spacing; idx < childCount; idx++) {
child = _getOrCreateChildAtIndex(idx, childConstraints, child);
child = _getOrCreateChildAtIndex(idx, constraints, child);
final childWidth = _childCrossExtent(child);
totalWidth += childWidth + _spacing;
@@ -215,24 +214,20 @@ class RenderSliverFixedWrap extends RenderSliverMultiBoxAdaptor {
final firstNeededRow = math.max(0, firstCacheOffset ~/ rowHeight);
final lastNeededRow = math.max(0, lastCacheOffset ~/ rowHeight);
final childConstraints = constraints.toFixedConstraints(_mainAxisExtent);
if (firstChild == null) {
if (!addInitialChild()) {
geometry = SliverGeometry.zero;
childManager.didFinishLayout();
return;
}
firstChild!.layout(
constraints.toFixedConstraints(_mainAxisExtent),
parentUsesSize: true,
);
firstChild!.layout(childConstraints, parentUsesSize: true);
}
while (_rows.length <= lastNeededRow) {
final int startIndex = _rows.isEmpty ? 0 : _rows.last.endIndex + 1;
if (!_buildNextRow(
startIndex,
constraints.toFixedConstraints(_mainAxisExtent),
)) {
if (!_buildNextRow(startIndex, childConstraints)) {
break;
}
}
@@ -256,11 +251,7 @@ class RenderSliverFixedWrap extends RenderSliverMultiBoxAdaptor {
final rowStartOffset = r * rowHeight;
double crossOffset = 0.0;
for (var i = row.startIndex; i <= row.endIndex; i++) {
child = _getOrCreateChildAtIndex(
i,
constraints.toFixedConstraints(_mainAxisExtent),
child,
);
child = _getOrCreateChildAtIndex(i, childConstraints, child);
(child.parentData as SliverWrapParentData)
..layoutOffset = rowStartOffset
..crossAxisOffset = crossOffset;