Skip to content

Instantly share code, notes, and snippets.

@mono0926
Last active May 15, 2019 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mono0926/e6f4b2238e02fdf5beb761b911b38a1c to your computer and use it in GitHub Desktop.
Save mono0926/e6f4b2238e02fdf5beb761b911b38a1c to your computer and use it in GitHub Desktop.
FadeTransitionの、opacityがゼロになったらVisibilityのvisibleがfalseになる版(透明Widgetの無駄がほぼゼロになる)
import 'package:flutter/widgets.dart';
class BetterFadeTransition extends AnimatedWidget {
const BetterFadeTransition({
Key key,
@required this.child,
@required Animation<double> opacity,
this.alwaysIncludeSemantics = false,
}) : super(
key: key,
listenable: opacity,
);
final Widget child;
final bool alwaysIncludeSemantics;
@override
Widget build(BuildContext context) {
final animation = listenable as Animation<double>;
return Visibility(
visible: animation.value != 0,
child: FadeTransition(
opacity: animation,
child: child,
alwaysIncludeSemantics: alwaysIncludeSemantics,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment