Steps to reproduce
To reproduce:
- extend BoxBorder class with your custom
- put created border in
AnimatedContainer with BoxDecoration
- 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!
Steps to reproduce
To reproduce:
AnimatedContainerwithBoxDecorationExpected 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
Flutter Doctor output