Fix visibility not set if initial opacity == 0

This commit is contained in:
Ming Ming 2021-09-14 13:39:40 +08:00
parent df45b23705
commit 1f4b43459c

View file

@ -27,6 +27,12 @@ class AnimatedVisibility extends StatefulWidget {
} }
class _AnimatedVisibilityState extends State<AnimatedVisibility> { class _AnimatedVisibilityState extends State<AnimatedVisibility> {
@override
initState() {
super.initState();
_isActive = widget.opacity > 0;
}
@override @override
build(BuildContext context) { build(BuildContext context) {
if (!_isActive && widget.opacity > 0) { if (!_isActive && widget.opacity > 0) {
@ -54,5 +60,5 @@ class _AnimatedVisibilityState extends State<AnimatedVisibility> {
widget.onEnd?.call(); widget.onEnd?.call();
} }
bool _isActive = true; late bool _isActive;
} }