Skip to content

Support custom BoxBorder animation in BoxDecoration#186348

Open
gabrimatic wants to merge 2 commits into
flutter:masterfrom
gabrimatic:gabrimatic/fix-custom-box-border-animation
Open

Support custom BoxBorder animation in BoxDecoration#186348
gabrimatic wants to merge 2 commits into
flutter:masterfrom
gabrimatic:gabrimatic/fix-custom-box-border-animation

Conversation

@gabrimatic
Copy link
Copy Markdown

Fixes #180297

BoxDecoration now preserves the existing specialized Border and BorderDirectional interpolation path, while custom BoxBorder subclasses use ShapeBorder.lerp. This lets custom borders provide their own interpolation hooks and avoids the AnimatedContainer assertion when animating a BoxDecoration with a custom border.

Tests:

  • ./bin/flutter test packages/flutter/test/painting/box_decoration_test.dart
  • ../../bin/dart analyze lib/src/painting/box_decoration.dart test/painting/box_decoration_test.dart

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label May 11, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enables BoxDecoration to handle interpolation and scaling for custom BoxBorder subclasses by introducing a private _lerpBorder method that utilizes ShapeBorder.lerp. New tests verify this functionality using a custom border implementation. Feedback suggests simplifying nullable type checks and renaming a local variable to avoid shadowing and improve idiomatic Dart usage.

Comment thread packages/flutter/lib/src/painting/box_decoration.dart
Comment thread packages/flutter/lib/src/painting/box_decoration.dart Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extending border and using it in animated scenarios throws exception

1 participant