Skip to content

Commit

Permalink
Revert "Sliver Constrained Cross Axis" (flutter#125233)
Browse files Browse the repository at this point in the history
Going to make some changes to the implementation so I'll revert in the meantime.

Reverts flutter#124337
  • Loading branch information
thkim1011 committed Apr 20, 2023
1 parent 0c7bc2f commit 9caabdd
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 238 deletions.

This file was deleted.

This file was deleted.

40 changes: 0 additions & 40 deletions packages/flutter/lib/src/rendering/proxy_sliver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:math';
import 'dart:ui' as ui show Color;

import 'package:flutter/animation.dart';
Expand Down Expand Up @@ -415,42 +414,3 @@ class RenderSliverAnimatedOpacity extends RenderProxySliver with RenderAnimatedO
child = sliver;
}
}

/// Applies a cross-axis constraint to its sliver child.
///
/// This render object takes a [maxExtent] parameter and uses the smaller of
/// [maxExtent] and the parent's [SliverConstraints.crossAxisExtent] as the
/// cross axis extent of the [SliverConstraints] passed to the sliver child.
class RenderSliverConstrainedCrossAxis extends RenderProxySliver {
/// Creates a render object that constrains the cross axis extent of its sliver child.
///
/// The [maxExtent] parameter must not be null and must be nonnegative.
RenderSliverConstrainedCrossAxis({
required double maxExtent
}) : _maxExtent = maxExtent,
assert(maxExtent >= 0.0);

/// The cross axis extent to apply to the sliver child.
///
/// This value must be nonnegative.
double get maxExtent => _maxExtent;
double _maxExtent;
set maxExtent(double value) {
if (_maxExtent == value) {
return;
}
_maxExtent = value;
markNeedsLayout();
}

@override
void performLayout() {
assert(child != null);
assert(maxExtent >= 0.0);
child!.layout(
constraints.copyWith(crossAxisExtent: min(_maxExtent, constraints.crossAxisExtent)),
parentUsesSize: true,
);
geometry = child!.geometry;
}
}
44 changes: 0 additions & 44 deletions packages/flutter/lib/src/widgets/sliver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1365,47 +1365,3 @@ class KeepAlive extends ParentDataWidget<KeepAliveParentDataMixin> {
properties.add(DiagnosticsProperty<bool>('keepAlive', keepAlive));
}
}

/// A sliver that constrains the cross axis extent of its sliver child.
///
/// The [SliverConstrainedCrossAxis] takes a [maxExtent] parameter and uses it as
/// the cross axis extent of the [SliverConstraints] passed to the sliver child.
/// The widget ensures that the [maxExtent] is a nonnegative value.
///
/// This is useful when you want to apply a custom cross-axis extent constraint
/// to a sliver child, as slivers typically consume the full cross axis extent.
///
/// {@tool dartpad}
/// In this sample the [SliverConstrainedCrossAxis] sizes its [child] so that the
/// cross axis extent takes up less space than the actual viewport.
///
/// ** See code in examples/api/lib/widgets/sliver/sliver_constrained_cross_axis.0.dart **
/// {@end-tool}
class SliverConstrainedCrossAxis extends SingleChildRenderObjectWidget {
/// Creates a sliver that constrains the cross axis extent of its sliver child.
///
/// The [maxExtent] parameter is required and must be nonnegative.
const SliverConstrainedCrossAxis({
super.key,
required this.maxExtent,
required Widget sliver,
}) : assert(maxExtent >= 0.0),
super(child: sliver);

/// The cross axis extent to apply to the sliver child.
///
/// This value must be nonnegative.
final double maxExtent;

@override
RenderSliverConstrainedCrossAxis createRenderObject(BuildContext context) {
return RenderSliverConstrainedCrossAxis(maxExtent: maxExtent);
}

@override
void updateRenderObject(
BuildContext context, RenderSliverConstrainedCrossAxis renderObject) {
renderObject.maxExtent = maxExtent;
}
}

This file was deleted.

0 comments on commit 9caabdd

Please sign in to comment.