-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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,
),
),
);
}
}
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
Status
Done (PR merged)