Skip to content

[Proposal] Allow disabling the scaling animation of the FloatingActionButton #145585

@navaronbracke

Description

@navaronbracke

Use case

Currently when the FloatingActionButton widget is added or removed from a Scaffold, it animates its transition.

We can control parts of this transition, using the FloatingActionButtonAnimator. By default this uses the scaling animator from the framework itself.

However, if I want to disable both the rotation and scaling animations with the following animator subclass:

class _NoAnimationFloatingActionButtonAnimator extends FloatingActionButtonAnimator {
  const _NoAnimationFloatingActionButtonAnimator();

  @override
  Offset getOffset({required Offset begin, required Offset end, required double progress}) {
    return end;
  }

  @override
  Animation<double> getRotationAnimation({required Animation<double> parent}) {
    return const AlwaysStoppedAnimation(1.0);
  }

  @override
  Animation<double> getScaleAnimation({required Animation<double> parent}) {
    return const AlwaysStoppedAnimation(1.0);
  }
}

and I pass an instance to the floatingActionButtonAnimator of a Scaffold, I still see a scale transition on the FAB.

Proposal

Allow disabling both the scaling and rotation transition, using the aforementioned FloatingActionButtonAnimator, either through a subclass, or by providing a FloatingActionButtonAnimator.noAnimation constant.

Metadata

Metadata

Assignees

Labels

a: animationAnimation APIsc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions