Skip to content

repeat on AnimationControlle does not calculate initial value correctly #142885

@paldepind

Description

@paldepind

Steps to reproduce

Example 1: Create an AnimationController like this:

controller = AnimationController(
        duration: const Duration(seconds: 2),
        vsync: this,
        lowerBound: 100,
        upperBound: 300);
controller.repeat();

Example 2: Create an AnimationController like this:

controller = AnimationController(
        duration: const Duration(seconds: 2),
        vsync: this,
        lowerBound: -100,
        upperBound: 200);
controller.repeat();

Expected results

The first animation starts with the value 100 and the second starts with the value -100.

Actual results

In the first example the animation starts with the value 200 and in the second example Flutter throws the following exception:

Assertion failed: file:///opt/flutter/packages/flutter/lib/src/animation/animation_controller.dart:889:12 _initialT >= 0.0 is not true

Code sample

Here is a DartPad that shows both issues: https://dartpad.dev/?id=79b890fd2a994d6e3f5ac210f433e7d5

Flutter Doctor output

Tested on the latest release and the latest main.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: animationAnimation APIsa: error messageError messages from the Flutter frameworkfound in release: 3.16Found to occur in 3.16found in release: 3.19Found to occur in 3.19frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions