Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 17be6d7

Browse files
authored
Revert "Configurable padding around FocusNodes in Scrollables" (#101772)
1 parent d07ce92 commit 17be6d7

File tree

6 files changed

+2
-482
lines changed

6 files changed

+2
-482
lines changed

packages/flutter/lib/src/widgets/focus_manager.dart

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -759,16 +759,6 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier {
759759
return null;
760760
}
761761

762-
/// Returns the amount of additional space to reveal around the attached widget
763-
/// when focused inside a scrolling container via [Scrollable.ensureVisible].
764-
///
765-
/// For example, a value of `EdgeInsets.all(16.0)` ensures 16 pixels of
766-
/// the adjacent widget are visible when this node receives focus.
767-
///
768-
/// By default, this returns [FocusManager.defaultEnsureVisiblePadding] from the
769-
/// associated [FocusManager], or [EdgeInsets.zero].
770-
EdgeInsets get ensureVisiblePadding => _manager?.defaultEnsureVisiblePadding ?? EdgeInsets.zero;
771-
772762
/// Returns the size of the attached widget's [RenderObject], in logical
773763
/// units.
774764
///
@@ -1720,20 +1710,6 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
17201710
return handled;
17211711
}
17221712

1723-
/// The default amount of additonal space to reveal when a widget is focused
1724-
/// inside a scrolling container via [Scrollable.ensureVisible].
1725-
///
1726-
/// Defaults to [EdgeInsets.zero], which does not add any additional space
1727-
/// when widgets are revealed.
1728-
///
1729-
/// For example, a value of `EdgeInsets.all(16.0)` ensures 16 pixels of
1730-
/// the adjacent widget are visible when focusing a widget inside of a
1731-
/// scrolling container.
1732-
///
1733-
/// Individual [FocusNode]s may increase or decrease this padding, use
1734-
/// [FocusNode.ensureVisiblePadding] to obtain a node's desired padding.
1735-
EdgeInsets defaultEnsureVisiblePadding = EdgeInsets.zero;
1736-
17371713
/// The node that currently has the primary focus.
17381714
FocusNode? get primaryFocus => _primaryFocus;
17391715
FocusNode? _primaryFocus;

packages/flutter/lib/src/widgets/focus_traversal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void _focusAndEnsureVisible(
3636
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicit,
3737
}) {
3838
node.requestFocus();
39-
Scrollable.ensureVisible(node.context!, alignment: 1.0, padding: node.ensureVisiblePadding, alignmentPolicy: alignmentPolicy);
39+
Scrollable.ensureVisible(node.context!, alignment: 1.0, alignmentPolicy: alignmentPolicy);
4040
}
4141

4242
// A class to temporarily hold information about FocusTraversalGroups when

packages/flutter/lib/src/widgets/page_view.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ class _PagePosition extends ScrollPositionWithSingleContext implements PageMetri
346346
Future<void> ensureVisible(
347347
RenderObject object, {
348348
double alignment = 0.0,
349-
EdgeInsets padding = EdgeInsets.zero,
350349
Duration duration = Duration.zero,
351350
Curve curve = Curves.ease,
352351
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicit,

packages/flutter/lib/src/widgets/scroll_position.dart

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,6 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
676676
/// Animates the position such that the given object is as visible as possible
677677
/// by just scrolling this position.
678678
///
679-
/// The [padding] is used to add extra space around the [object] when revealing it.
680-
/// For example, `EdgeInsets.only(bottom: 16.0)` will ensure an additional 16 pixels
681-
/// of space are visible below the [object].
682-
///
683679
/// The optional `targetRenderObject` parameter is used to determine which area
684680
/// of that object should be as visible as possible. If `targetRenderObject`
685681
/// is null, the entire [RenderObject] (as defined by its
@@ -690,12 +686,9 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
690686
///
691687
/// * [ScrollPositionAlignmentPolicy] for the way in which `alignment` is
692688
/// applied, and the way the given `object` is aligned.
693-
/// * [FocusNode.ensureVisiblePadding] which specifies the [padding] used when
694-
/// a widget is focused via focus traversal.
695689
Future<void> ensureVisible(
696690
RenderObject object, {
697691
double alignment = 0.0,
698-
EdgeInsets padding = EdgeInsets.zero,
699692
Duration duration = Duration.zero,
700693
Curve curve = Curves.ease,
701694
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicit,
@@ -706,18 +699,14 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
706699
final RenderAbstractViewport viewport = RenderAbstractViewport.of(object)!;
707700
assert(viewport != null);
708701

709-
Rect targetRect;
702+
Rect? targetRect;
710703
if (targetRenderObject != null && targetRenderObject != object) {
711704
targetRect = MatrixUtils.transformRect(
712705
targetRenderObject.getTransformTo(object),
713706
object.paintBounds.intersect(targetRenderObject.paintBounds),
714707
);
715-
} else {
716-
targetRect = object.paintBounds;
717708
}
718709

719-
targetRect = padding.inflateRect(targetRect);
720-
721710
double target;
722711
switch (alignmentPolicy) {
723712
case ScrollPositionAlignmentPolicy.explicit:

packages/flutter/lib/src/widgets/scrollable.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -311,19 +311,9 @@ class Scrollable extends StatefulWidget {
311311

312312
/// Scrolls the scrollables that enclose the given context so as to make the
313313
/// given context visible.
314-
///
315-
/// The [padding] is used to add extra space around the [context]'s
316-
/// associated widget when revealing it. For example, `EdgeInsets.only(bottom: 16.0)`
317-
/// will ensure an additional 16 pixels of space are visible below the widget.
318-
///
319-
/// See also:
320-
///
321-
/// * [FocusNode.ensureVisiblePadding] which specifies the [padding] used when
322-
/// a widget is focused via focus traversal.
323314
static Future<void> ensureVisible(
324315
BuildContext context, {
325316
double alignment = 0.0,
326-
EdgeInsets padding = EdgeInsets.zero,
327317
Duration duration = Duration.zero,
328318
Curve curve = Curves.ease,
329319
ScrollPositionAlignmentPolicy alignmentPolicy = ScrollPositionAlignmentPolicy.explicit,
@@ -342,7 +332,6 @@ class Scrollable extends StatefulWidget {
342332
futures.add(scrollable.position.ensureVisible(
343333
context.findRenderObject()!,
344334
alignment: alignment,
345-
padding: padding,
346335
duration: duration,
347336
curve: curve,
348337
alignmentPolicy: alignmentPolicy,

0 commit comments

Comments
 (0)