chore: bump line length to 120 (#20191)

This commit is contained in:
shenlong 2025-07-25 08:07:22 +05:30 committed by GitHub
parent 977c9b96ba
commit ad65e9011a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
517 changed files with 4520 additions and 9514 deletions

View file

@ -101,8 +101,7 @@ class _SliverTimelineState extends ConsumerState<_SliverTimeline> {
@override
void initState() {
super.initState();
_reloadSubscription =
EventStream.shared.listen<TimelineReloadEvent>((_) => setState(() {}));
_reloadSubscription = EventStream.shared.listen<TimelineReloadEvent>((_) => setState(() {}));
}
@override
@ -115,8 +114,7 @@ class _SliverTimelineState extends ConsumerState<_SliverTimeline> {
@override
Widget build(BuildContext _) {
final asyncSegments = ref.watch(timelineSegmentProvider);
final maxHeight =
ref.watch(timelineArgsProvider.select((args) => args.maxHeight));
final maxHeight = ref.watch(timelineArgsProvider.select((args) => args.maxHeight));
final isSelectionMode = ref.watch(
multiSelectProvider.select((s) => s.forceEnable),
);
@ -124,17 +122,11 @@ class _SliverTimelineState extends ConsumerState<_SliverTimeline> {
return asyncSegments.widgetWhen(
onData: (segments) {
final childCount = (segments.lastOrNull?.lastIndex ?? -1) + 1;
final double appBarExpandedHeight =
widget.appBar != null && widget.appBar is MesmerizingSliverAppBar
? 200
: 0;
final topPadding = context.padding.top +
(widget.appBar == null ? 0 : kToolbarHeight) +
10;
final double appBarExpandedHeight = widget.appBar != null && widget.appBar is MesmerizingSliverAppBar ? 200 : 0;
final topPadding = context.padding.top + (widget.appBar == null ? 0 : kToolbarHeight) + 10;
const scrubberBottomPadding = 100.0;
final bottomPadding = context.padding.bottom +
(widget.appBar == null ? 0 : scrubberBottomPadding);
final bottomPadding = context.padding.bottom + (widget.appBar == null ? 0 : scrubberBottomPadding);
return PrimaryScrollController(
controller: _scrollController,
@ -145,16 +137,12 @@ class _SliverTimelineState extends ConsumerState<_SliverTimeline> {
timelineHeight: maxHeight,
topPadding: topPadding,
bottomPadding: bottomPadding,
monthSegmentSnappingOffset:
widget.topSliverWidgetHeight ?? 0 + appBarExpandedHeight,
monthSegmentSnappingOffset: widget.topSliverWidgetHeight ?? 0 + appBarExpandedHeight,
child: CustomScrollView(
primary: true,
cacheExtent: maxHeight * 2,
slivers: [
if (isSelectionMode)
const SelectionSliverAppBar()
else if (widget.appBar != null)
widget.appBar!,
if (isSelectionMode) const SelectionSliverAppBar() else if (widget.appBar != null) widget.appBar!,
if (widget.topSliverWidget != null) widget.topSliverWidget!,
_SliverSegmentedList(
segments: segments,
@ -162,8 +150,7 @@ class _SliverTimelineState extends ConsumerState<_SliverTimeline> {
(ctx, index) {
if (index >= childCount) return null;
final segment = segments.findByIndex(index);
return segment?.builder(ctx, index) ??
const SizedBox.shrink();
return segment?.builder(ctx, index) ?? const SizedBox.shrink();
},
childCount: childCount,
addAutomaticKeepAlives: false,
@ -233,8 +220,7 @@ class _SliverSegmentedList extends SliverMultiBoxAdaptorWidget {
}) : _segments = segments;
@override
_RenderSliverTimelineBoxAdaptor createRenderObject(BuildContext context) =>
_RenderSliverTimelineBoxAdaptor(
_RenderSliverTimelineBoxAdaptor createRenderObject(BuildContext context) => _RenderSliverTimelineBoxAdaptor(
childManager: context as SliverMultiBoxAdaptorElement,
segments: _segments,
);
@ -266,17 +252,13 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
}) : _segments = segments;
int getMinChildIndexForScrollOffset(double offset) =>
_segments.findByOffset(offset)?.getMinChildIndexForScrollOffset(offset) ??
0;
_segments.findByOffset(offset)?.getMinChildIndexForScrollOffset(offset) ?? 0;
int getMaxChildIndexForScrollOffset(double offset) =>
_segments.findByOffset(offset)?.getMaxChildIndexForScrollOffset(offset) ??
0;
_segments.findByOffset(offset)?.getMaxChildIndexForScrollOffset(offset) ?? 0;
double indexToLayoutOffset(int index) =>
(_segments.findByIndex(index) ?? _segments.lastOrNull)
?.indexToLayoutOffset(index) ??
0;
(_segments.findByIndex(index) ?? _segments.lastOrNull)?.indexToLayoutOffset(index) ?? 0;
double estimateMaxScrollOffset() => _segments.lastOrNull?.endOffset ?? 0;
@ -288,8 +270,7 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
// Assume initially that we have enough children to fill the viewport/cache area.
childManager.setDidUnderflow(false);
final double scrollOffset =
constraints.scrollOffset + constraints.cacheOrigin;
final double scrollOffset = constraints.scrollOffset + constraints.cacheOrigin;
assert(scrollOffset >= 0.0);
final double remainingExtent = constraints.remainingCacheExtent;
@ -298,31 +279,26 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
final double targetScrollOffset = scrollOffset + remainingExtent;
// Find the index of the first child that should be visible or in the leading cache area.
final int firstRequiredChildIndex =
getMinChildIndexForScrollOffset(scrollOffset);
final int firstRequiredChildIndex = getMinChildIndexForScrollOffset(scrollOffset);
// Find the index of the last child that should be visible or in the trailing cache area.
final int? lastRequiredChildIndex = targetScrollOffset.isFinite
? getMaxChildIndexForScrollOffset(targetScrollOffset)
: null;
final int? lastRequiredChildIndex =
targetScrollOffset.isFinite ? getMaxChildIndexForScrollOffset(targetScrollOffset) : null;
// Remove children that are no longer visible or within the cache area.
if (firstChild == null) {
collectGarbage(0, 0);
} else {
final int leadingChildrenToRemove =
calculateLeadingGarbage(firstIndex: firstRequiredChildIndex);
final int trailingChildrenToRemove = lastRequiredChildIndex == null
? 0
: calculateTrailingGarbage(lastIndex: lastRequiredChildIndex);
final int leadingChildrenToRemove = calculateLeadingGarbage(firstIndex: firstRequiredChildIndex);
final int trailingChildrenToRemove =
lastRequiredChildIndex == null ? 0 : calculateTrailingGarbage(lastIndex: lastRequiredChildIndex);
collectGarbage(leadingChildrenToRemove, trailingChildrenToRemove);
}
// If there are currently no children laid out (e.g., initial load),
// try to add the first child needed for the current scroll offset.
if (firstChild == null) {
final double firstChildLayoutOffset =
indexToLayoutOffset(firstRequiredChildIndex);
final double firstChildLayoutOffset = indexToLayoutOffset(firstRequiredChildIndex);
final bool childAdded = addInitialChild(
index: firstRequiredChildIndex,
layoutOffset: firstChildLayoutOffset,
@ -330,8 +306,7 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
if (!childAdded) {
// There are either no children, or we are past the end of all our children.
final double max =
firstRequiredChildIndex <= 0 ? 0.0 : computeMaxScrollOffset();
final double max = firstRequiredChildIndex <= 0 ? 0.0 : computeMaxScrollOffset();
geometry = SliverGeometry(scrollExtent: max, maxPaintExtent: max);
childManager.didFinishLayout();
return;
@ -342,26 +317,20 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
RenderBox? highestLaidOutChild;
final childConstraints = constraints.asBoxConstraints();
for (int currentIndex = indexOf(firstChild!) - 1;
currentIndex >= firstRequiredChildIndex;
--currentIndex) {
final RenderBox? newLeadingChild =
insertAndLayoutLeadingChild(childConstraints);
for (int currentIndex = indexOf(firstChild!) - 1; currentIndex >= firstRequiredChildIndex; --currentIndex) {
final RenderBox? newLeadingChild = insertAndLayoutLeadingChild(childConstraints);
if (newLeadingChild == null) {
// If a child is missing where we expect one, it indicates
// an inconsistency in offset that needs correction.
final Segment? segment =
_segments.findByIndex(currentIndex) ?? _segments.firstOrNull;
final Segment? segment = _segments.findByIndex(currentIndex) ?? _segments.firstOrNull;
geometry = SliverGeometry(
// Request a scroll correction based on where the missing child should have been.
scrollOffsetCorrection:
segment?.indexToLayoutOffset(currentIndex) ?? 0.0,
scrollOffsetCorrection: segment?.indexToLayoutOffset(currentIndex) ?? 0.0,
);
// Parent will re-layout everything.
return;
}
final childParentData =
newLeadingChild.parentData! as SliverMultiBoxAdaptorParentData;
final childParentData = newLeadingChild.parentData! as SliverMultiBoxAdaptorParentData;
childParentData.layoutOffset = indexToLayoutOffset(currentIndex);
assert(childParentData.index == currentIndex);
highestLaidOutChild ??= newLeadingChild;
@ -375,10 +344,8 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
// The [firstChild] that existed at the start of performLayout is still the first one we need.
if (highestLaidOutChild == null) {
firstChild!.layout(childConstraints);
final childParentData =
firstChild!.parentData! as SliverMultiBoxAdaptorParentData;
childParentData.layoutOffset =
indexToLayoutOffset(firstRequiredChildIndex);
final childParentData = firstChild!.parentData! as SliverMultiBoxAdaptorParentData;
childParentData.layoutOffset = indexToLayoutOffset(firstRequiredChildIndex);
highestLaidOutChild = firstChild;
}
@ -389,8 +356,7 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
double calculatedMaxScrollOffset = double.infinity;
for (int currentIndex = indexOf(mostRecentlyLaidOutChild!) + 1;
lastRequiredChildIndex == null ||
currentIndex <= lastRequiredChildIndex;
lastRequiredChildIndex == null || currentIndex <= lastRequiredChildIndex;
++currentIndex) {
RenderBox? child = childAfter(mostRecentlyLaidOutChild!);
@ -400,11 +366,8 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
after: mostRecentlyLaidOutChild,
);
if (child == null) {
final Segment? segment =
_segments.findByIndex(currentIndex) ?? _segments.lastOrNull;
calculatedMaxScrollOffset =
segment?.indexToLayoutOffset(currentIndex) ??
computeMaxScrollOffset();
final Segment? segment = _segments.findByIndex(currentIndex) ?? _segments.lastOrNull;
calculatedMaxScrollOffset = segment?.indexToLayoutOffset(currentIndex) ?? computeMaxScrollOffset();
break;
}
} else {
@ -412,28 +375,23 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
}
mostRecentlyLaidOutChild = child;
final childParentData = mostRecentlyLaidOutChild.parentData!
as SliverMultiBoxAdaptorParentData;
final childParentData = mostRecentlyLaidOutChild.parentData! as SliverMultiBoxAdaptorParentData;
assert(childParentData.index == currentIndex);
childParentData.layoutOffset = indexToLayoutOffset(currentIndex);
}
final int lastLaidOutChildIndex = indexOf(lastChild!);
final double leadingScrollOffset =
indexToLayoutOffset(firstRequiredChildIndex);
final double trailingScrollOffset =
indexToLayoutOffset(lastLaidOutChildIndex + 1);
final double leadingScrollOffset = indexToLayoutOffset(firstRequiredChildIndex);
final double trailingScrollOffset = indexToLayoutOffset(lastLaidOutChildIndex + 1);
assert(
firstRequiredChildIndex == 0 ||
(childScrollOffset(firstChild!) ?? -1.0) - scrollOffset <=
precisionErrorTolerance,
(childScrollOffset(firstChild!) ?? -1.0) - scrollOffset <= precisionErrorTolerance,
);
assert(debugAssertChildListIsNonEmptyAndContiguous());
assert(indexOf(firstChild!) == firstRequiredChildIndex);
assert(
lastRequiredChildIndex == null ||
lastLaidOutChildIndex <= lastRequiredChildIndex,
lastRequiredChildIndex == null || lastLaidOutChildIndex <= lastRequiredChildIndex,
);
calculatedMaxScrollOffset = math.min(
@ -453,11 +411,9 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
to: trailingScrollOffset,
);
final double targetEndScrollOffsetForPaint =
constraints.scrollOffset + constraints.remainingPaintExtent;
final int? targetLastIndexForPaint = targetEndScrollOffsetForPaint.isFinite
? getMaxChildIndexForScrollOffset(targetEndScrollOffsetForPaint)
: null;
final double targetEndScrollOffsetForPaint = constraints.scrollOffset + constraints.remainingPaintExtent;
final int? targetLastIndexForPaint =
targetEndScrollOffsetForPaint.isFinite ? getMaxChildIndexForScrollOffset(targetEndScrollOffsetForPaint) : null;
final maxPaintExtent = math.max(paintExtent, calculatedMaxScrollOffset);
@ -468,8 +424,7 @@ class _RenderSliverTimelineBoxAdaptor extends RenderSliverMultiBoxAdaptor {
// Indicates if there's content scrolled off-screen.
// This is true if the last child needed for painting is actually laid out,
// or if the first child is partially visible.
hasVisualOverflow: (targetLastIndexForPaint != null &&
lastLaidOutChildIndex >= targetLastIndexForPaint) ||
hasVisualOverflow: (targetLastIndexForPaint != null && lastLaidOutChildIndex >= targetLastIndexForPaint) ||
constraints.scrollOffset > 0.0,
cacheExtent: cacheExtent,
);
@ -489,8 +444,7 @@ class _MultiSelectStatusButton extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final selectCount =
ref.watch(multiSelectProvider.select((s) => s.selectedAssets.length));
final selectCount = ref.watch(multiSelectProvider.select((s) => s.selectedAssets.length));
return ElevatedButton.icon(
onPressed: () => ref.read(multiSelectProvider.notifier).reset(),
icon: Icon(