Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Sliver Constrained Cross Axis" #125233

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

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.