Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5f2d730

Browse files
authored
Revert Ballistic & Clamping simulation updates (#111201)
1 parent dc6ab62 commit 5f2d730

12 files changed

+58
-448
lines changed

dev/tools/generate_android_spline_data.dart

Lines changed: 0 additions & 61 deletions
This file was deleted.

packages/flutter/lib/src/animation/animation_controller.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -757,15 +757,6 @@ class AnimationController extends Animation<double>
757757
return result;
758758
}
759759

760-
/// Update the simulation without restarting the animation.
761-
///
762-
/// The current simulation will be replaced with the provided [Simulation].
763-
/// It is only valid to call this when an animation is currently underway.
764-
void updateSimulation(Simulation simulation) {
765-
assert(isAnimating);
766-
_simulation = simulation;
767-
}
768-
769760
/// Stops running this animation.
770761
///
771762
/// This does not trigger any notifications. The animation stops in its

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -686,12 +686,6 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont
686686
);
687687
}
688688

689-
// TODO(Piinks): https://github.com/flutter/flutter/issues/100748
690-
@override
691-
Simulation? updateBallisticAnimation(double initVelocity, double initPosition) {
692-
return null;
693-
}
694-
695689
ScrollActivity createOuterBallisticScrollActivity(double velocity) {
696690
// This function creates a ballistic scroll for the outer scrollable.
697691
//
@@ -1367,12 +1361,6 @@ class _NestedScrollPosition extends ScrollPosition implements ScrollActivityDele
13671361
));
13681362
}
13691363

1370-
// TODO(Piinks): see https://github.com/flutter/flutter/issues/100748
1371-
@override
1372-
Simulation? updateBallisticAnimation(double initVelocity, double initPosition) {
1373-
return null;
1374-
}
1375-
13761364
ScrollActivity createBallisticScrollActivity(
13771365
Simulation? simulation, {
13781366
required _NestedBallisticScrollActivityMode mode,

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

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ abstract class ScrollActivityDelegate {
4747
/// Terminate the current activity and start a ballistic activity with the
4848
/// given velocity.
4949
void goBallistic(double velocity);
50-
51-
/// Update the ballistic animation instead of restarting it, for example as
52-
/// the result of a layout change after a flinging gesture.
53-
///
54-
/// The [initVelocity] and [initPosition] refer to the starting values of the
55-
/// new ballistic animation.
56-
///
57-
/// Can return null if the current [ScrollPhysics.createBallisticSimulation]
58-
/// returns null, which will trigger an [IdleScrollActivity] instead.
59-
Simulation? updateBallisticAnimation(double initVelocity, double initPosition);
6050
}
6151

6252
/// Base class for scrolling activities like dragging and flinging.
@@ -534,17 +524,13 @@ class DragScrollActivity extends ScrollActivity {
534524
class BallisticScrollActivity extends ScrollActivity {
535525
/// Creates an activity that animates a scroll view based on a [simulation].
536526
///
537-
/// The [delegate], [simulation], and [vsync] arguments must not be null. The
538-
/// [initVelocity] and [initPosition] arguments allow the ballistic activity
539-
/// to update the simulation instead of restarting it.
527+
/// The [delegate], [simulation], and [vsync] arguments must not be null.
540528
BallisticScrollActivity(
541529
super.delegate,
542530
Simulation simulation,
543531
TickerProvider vsync,
544-
this.shouldIgnorePointer, {
545-
double initVelocity = 0.0,
546-
double initPosition = 0.0,
547-
}) : _initVelocity = initVelocity, _initPosition = initPosition {
532+
this.shouldIgnorePointer,
533+
) {
548534
_controller = AnimationController.unbounded(
549535
debugLabel: kDebugMode ? objectRuntimeType(this, 'BallisticScrollActivity') : null,
550536
vsync: vsync,
@@ -556,24 +542,14 @@ class BallisticScrollActivity extends ScrollActivity {
556542

557543
late AnimationController _controller;
558544

559-
final double _initVelocity;
560-
561-
final double _initPosition;
562-
563545
@override
564546
void resetActivity() {
565547
delegate.goBallistic(velocity);
566548
}
567549

568550
@override
569551
void applyNewDimensions() {
570-
final Simulation? newSimulation = delegate.updateBallisticAnimation(
571-
_initVelocity,
572-
_initPosition,
573-
);
574-
if (newSimulation != null) {
575-
_controller.updateSimulation(newSimulation);
576-
}
552+
delegate.goBallistic(velocity);
577553
}
578554

579555
void _tick() {

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import 'basic.dart';
1212
import 'framework.dart';
1313
import 'scroll_activity.dart';
1414
import 'scroll_context.dart';
15-
import 'scroll_metrics.dart';
1615
import 'scroll_notification.dart';
1716
import 'scroll_physics.dart';
1817
import 'scroll_position.dart';
@@ -147,35 +146,12 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc
147146
simulation,
148147
context.vsync,
149148
activity?.shouldIgnorePointer ?? true,
150-
initVelocity: velocity,
151-
initPosition: pixels,
152149
));
153150
} else {
154151
goIdle();
155152
}
156153
}
157154

158-
@override
159-
Simulation? updateBallisticAnimation(double initVelocity, double initPosition) {
160-
assert(hasPixels);
161-
final FixedScrollMetrics initScrollMetrics = FixedScrollMetrics(
162-
minScrollExtent: minScrollExtent,
163-
maxScrollExtent: maxScrollExtent,
164-
pixels: initPosition,
165-
viewportDimension: viewportDimension,
166-
axisDirection: axisDirection,
167-
);
168-
final Simulation? simulation = physics.createBallisticSimulation(
169-
initScrollMetrics,
170-
initVelocity,
171-
);
172-
if (simulation == null) {
173-
goIdle();
174-
return null;
175-
}
176-
return simulation;
177-
}
178-
179155
@override
180156
ScrollDirection get userScrollDirection => _userScrollDirection;
181157
ScrollDirection _userScrollDirection = ScrollDirection.idle;

0 commit comments

Comments
 (0)