Repository navigation
TrainHoppingAnimation Calls notifyListeners() on Status Change Instead of notifyStatusListeners() #178336
Copy link
Copy link
Closed
Labels
a: animationAnimation APIsAnimation APIsframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework team
Description
In its animation status listener, TrainHoppingAnimation calls notifyListeners() on status change when it should call notifyStatusListeners().
flutter/packages/flutter/lib/src/animation/animations.dart
Lines 542 to 550 in b1d5f03
| AnimationStatus? _lastStatus; | |
| void _statusChangeHandler(AnimationStatus status) { | |
| assert(_currentTrain != null); | |
| if (status != _lastStatus) { | |
| notifyListeners(); | |
| _lastStatus = status; | |
| } | |
| assert(_lastStatus != null); | |
| } |
Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const App());
}
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: Screen(),
);
}
}
class Screen extends StatefulWidget {
const Screen({super.key});
@override
State<Screen> createState() => _ScreenState();
}
class _ScreenState extends State<Screen> with SingleTickerProviderStateMixin {
late final _controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 3),
);
late final _animation = TrainHoppingAnimation(
Tween<double>(begin: 1, end: 0).animate(_controller),
Tween<double>(begin: 0, end: 1).animate(_controller),
);
@override
void initState() {
super.initState();
_controller.addStatusListener((status) {
print('controller: $status');
});
_animation.addStatusListener((status) {
print('animation: $status');
});
_controller.forward();
}
@override
void dispose() {
_animation.dispose();
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Center(
child: ScaleTransition(
scale: _animation,
child: Container(
color: Colors.red,
height: 200,
width: 200,
),
),
);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a: animationAnimation APIsAnimation APIsframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework team
Type
Projects
- StatusShow more project fieldsDone (PR merged)
Activity
darshankawar commentedon Nov 12, 2025
@swrenn Can you provide us a code example that shows the current behavior versus expected behavior ?
Below is a sample code based on the issue you described it shortly:
runnable code
which prints below:
Please check if above correctly interprets the issue you are reporting or please update it to show current behavior as compared to expected.
ksokolovskyi commentedon Nov 12, 2025
Hi @darshankawar, thanks a lot for taking a look at this issue. I've added a code sample to the issue. May I ask you to try it?
darshankawar commentedon Nov 12, 2025
Thanks @ksokolovskyi for the code. With it, I get below which doesn't seem to notify all statuses.
While https://api.flutter.dev/flutter/animation/AnimationLocalStatusListenersMixin/notifyStatusListeners.html does mention that it calls all status listeners, so ideally it should be called instead of
notifyListeners.Fix train hopping animation status listeners (#178372)
Fix train hopping animation status listeners (flutter#178372)
Fix train hopping animation status listeners (flutter#178372)
Fix train hopping animation status listeners (flutter#178372)
github-actions commentedon Dec 3, 2025
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.Fix train hopping animation status listeners (flutter#178372)
Fix train hopping animation status listeners (#178372)