Commit ec9df2f2 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Allow Duration.Zero for animateTo (#11515)

parent 802d5d20
......@@ -341,7 +341,10 @@ class AnimationController extends Animation<double>
}
stop();
if (simulationDuration == Duration.ZERO) {
assert(value == target);
if (value != target) {
_value = target.clamp(lowerBound, upperBound);
notifyListeners();
}
_status = (_direction == _AnimationDirection.forward) ?
AnimationStatus.completed :
AnimationStatus.dismissed;
......
......@@ -6,6 +6,7 @@ import 'dart:ui' as ui;
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/animation.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import '../scheduler/scheduler_tester.dart';
......@@ -381,4 +382,17 @@ void main() {
expect(statusLog, equals(<AnimationStatus>[ AnimationStatus.reverse, AnimationStatus.dismissed ]));
expect(controller.value, currentValue);
});
test('animateTo can deal with duration == Duration.ZERO', () {
final AnimationController controller = new AnimationController(
duration: const Duration(milliseconds: 100),
vsync: const TestVSync(),
);
controller.forward(from: 0.2);
expect(controller.value, 0.2);
controller.animateTo(1.0, duration: Duration.ZERO);
expect(SchedulerBinding.instance.transientCallbackCount, equals(0), reason: 'Expected no animation.');
expect(controller.value, 1.0);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment