Implement new AnimationStatus getters (#148570)
PR #147801 introduced some convenient `AnimationStatus` getters, but I just realized that `AnimationController` now has 2 getters for the same thing: `isAnimating` and `isRunning`. The intent of this pull request is to correct that mistake, and implement the getters in the appropriate places.
This commit is contained in:
@@ -276,13 +276,8 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
|
||||
});
|
||||
}
|
||||
|
||||
bool get _backdropPanelVisible {
|
||||
final AnimationStatus status = _controller.status;
|
||||
return status == AnimationStatus.completed || status == AnimationStatus.forward;
|
||||
}
|
||||
|
||||
void _toggleBackdropPanelVisibility() {
|
||||
_controller.fling(velocity: _backdropPanelVisible ? -2.0 : 2.0);
|
||||
_controller.fling(velocity: _controller.isForwardOrCompleted ? -2.0 : 2.0);
|
||||
}
|
||||
|
||||
double get _backdropHeight {
|
||||
@@ -294,7 +289,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
|
||||
// the user must either tap its heading or the backdrop's menu icon.
|
||||
|
||||
void _handleDragUpdate(DragUpdateDetails details) {
|
||||
if (_controller.isAnimating || _controller.status == AnimationStatus.completed) {
|
||||
if (!_controller.isDismissed) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -302,7 +297,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
|
||||
}
|
||||
|
||||
void _handleDragEnd(DragEndDetails details) {
|
||||
if (_controller.isAnimating || _controller.status == AnimationStatus.completed) {
|
||||
if (!_controller.isDismissed) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -231,10 +231,7 @@ class ExpandingBottomSheetState extends State<ExpandingBottomSheet> with TickerP
|
||||
}
|
||||
|
||||
// Returns true if the cart is open or opening and false otherwise.
|
||||
bool get _isOpen {
|
||||
final AnimationStatus status = _controller.status;
|
||||
return status == AnimationStatus.completed || status == AnimationStatus.forward;
|
||||
}
|
||||
bool get _isOpen => _controller.isForwardOrCompleted;
|
||||
|
||||
// Opens the ExpandingBottomSheet if it's closed, otherwise does nothing.
|
||||
void open() {
|
||||
|
||||
@@ -241,7 +241,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
||||
}
|
||||
|
||||
void _handleDragEnd(DragEndDetails details) {
|
||||
if (_controller!.isAnimating || _controller!.status == AnimationStatus.completed) {
|
||||
if (!_controller!.isDismissed) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -254,9 +254,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
||||
}
|
||||
|
||||
void _toggleFrontLayer() {
|
||||
final AnimationStatus status = _controller!.status;
|
||||
final bool isOpen = status == AnimationStatus.completed || status == AnimationStatus.forward;
|
||||
_controller!.fling(velocity: isOpen ? -2.0 : 2.0);
|
||||
_controller!.fling(velocity: _controller!.isForwardOrCompleted ? -2.0 : 2.0);
|
||||
}
|
||||
|
||||
Widget _buildStack(BuildContext context, BoxConstraints constraints) {
|
||||
@@ -293,7 +291,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
|
||||
AnimationStatus.dismissed,
|
||||
controller: _controller,
|
||||
child: Visibility(
|
||||
visible: _controller!.status != AnimationStatus.completed,
|
||||
visible: !_controller!.isCompleted,
|
||||
maintainState: true,
|
||||
child: widget.backLayer!,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user