Repository navigation
Extending border and using it in animated scenarios throws exception #180297
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: animationAnimation APIsAnimation APIsa: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkfound in release: 3.38Found to occur in 3.38Found to occur in 3.38found in release: 3.40Found to occur in 3.40Found to occur in 3.40frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
Steps to reproduce
To reproduce:
- extend BoxBorder class with your custom
- put created border in
AnimatedContainerwithBoxDecoration - change param of your border (e.g. color)
BoxBorder.lerp can only interpolate Border and BorderDirectional classes.
BoxBorder.lerp() was called with two objects of type GradientBoxBorder and GradientBoxBorder:
2
GradientBoxBorder()
However, only Border and BorderDirectional classes are supported by this method.
For a more general interpolation method, consider using ShapeBorder.lerp instead.
Expected results
I should be able to provide way to interpolate my border for the framework.
Extending a class that is not final should not break anything internally the framework.
I should not be forced to write custom container or decoration if I only want to change one param.
As a package provider I want to share some custom decorations implementations.
Actual results
During the animation view shows red error wall.
Code sample
I have reproduction sample on this branch:
https://github.com/obiwanzenobi/gradient-borders/tree/fix/support-animated-container
run it and hit the button in the appbar
Screenshots or Video
Logs
════════ Exception caught by widgets library ═══════════════════════════════════
The following assertion was thrown building AnimatedContainer(duration: 500ms, bg: BoxDecoration(border: GradientBoxBorder(), borderRadius: BorderRadius.circular(16.0)), BoxConstraints(w=100.0, h=100.0), clipBehavior: Clip.none, dirty, state: _AnimatedContainerState#c9f36(ticker active, bg: DecorationTween(BoxDecoration(border: GradientBoxBorder(), borderRadius: BorderRadius.circular(16.0)) → BoxDecoration(border: GradientBoxBorder(), borderRadius: BorderRadius.circular(16.0))), BoxConstraintsTween(BoxConstraints(w=100.0, h=100.0) → BoxConstraints(w=100.0, h=100.0)))):
BoxBorder.lerp can only interpolate Border and BorderDirectional classes.
BoxBorder.lerp() was called with two objects of type GradientBoxBorder and GradientBoxBorder:
2
GradientBoxBorder()
However, only Border and BorderDirectional classes are supported by this method.
For a more general interpolation method, consider using ShapeBorder.lerp instead.
The relevant error-causing widget was:
AnimatedContainer AnimatedContainer:file:///Users/obiwanzenobi/Projects/gradient-borders/example/lib/main.dart:54:13
When the exception was thrown, this was the stack:
#0 BoxBorder.lerp (package:flutter/src/painting/box_border.dart:206:5)
box_border.dart:206
#1 BoxDecoration.lerp (package:flutter/src/painting/box_decoration.dart:309:25)
box_decoration.dart:309
#2 BoxDecoration.lerpFrom (package:flutter/src/painting/box_decoration.dart:256:38)
box_decoration.dart:256
#3 Decoration.lerp (package:flutter/src/painting/decoration.dart:154:14)
decoration.dart:154
#4 DecorationTween.lerp (package:flutter/src/widgets/implicit_animations.dart:84:43)
implicit_animations.dart:84
#5 Tween.transform (package:flutter/src/animation/tween.dart:369:12)
tween.dart:369
#6 Animatable.evaluate (package:flutter/src/animation/tween.dart:71:46)
tween.dart:71
#7 _AnimatedContainerState.build (package:flutter/src/widgets/implicit_animations.dart:830:32)
implicit_animations.dart:830
Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.32.8, on macOS 26.1 25B78 darwin-arm64, locale pl-PL)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
[✓] Xcode - develop for iOS and macOS (Xcode 26.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2025.1)
[✓] VS Code (version 1.107.1)
[✓] Connected device (3 available)
[✓] Network resources
• No issues found!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: animationAnimation APIsAnimation APIsa: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkfound in release: 3.38Found to occur in 3.38Found to occur in 3.38found in release: 3.40Found to occur in 3.40Found to occur in 3.40frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Activity
tirth-patel-nc commentedon Jan 2, 2026
Thanks for the report. Seeing the same behaviour with latest SDK versions.
justinmc commentedon Jan 14, 2026
@obiwanzenobi Can you paste in a runnable repro of this?
obiwanzenobi commentedon Jan 14, 2026
Yes, I will put single file repro tomorrow - in the meantime you can check repository attached in the issue - which has runnable reproduction scenario
marejonc commentedon Mar 9, 2026
@justinmc Here is a condensed repro
Support custom BoxBorder animation in BoxDecoration (flutter#186348)
github-actions commentedon Aug 5, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.