mirror of
https://github.com/flutter/flutter
synced 2024-10-14 04:02:56 +00:00
Add sample code to FadeTransition (#64240)
This commit is contained in:
parent
2e643651a9
commit
a39a893463
|
@ -660,7 +660,49 @@ class SizeTransition extends AnimatedWidget {
|
|||
/// Here's an illustration of the [FadeTransition] widget, with it's [opacity]
|
||||
/// animated by a [CurvedAnimation] set to [Curves.fastOutSlowIn]:
|
||||
///
|
||||
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/fade_transition.mp4}
|
||||
/// {@tool dartpad --template=stateful_widget_material_ticker}
|
||||
///
|
||||
/// The following code implements the [FadeTransition] using
|
||||
/// the Flutter logo:
|
||||
///
|
||||
/// ```dart
|
||||
/// AnimationController _controller;
|
||||
/// Animation<double> _animation;
|
||||
///
|
||||
/// @override
|
||||
/// void initState() {
|
||||
/// super.initState();
|
||||
/// _controller = AnimationController(
|
||||
/// duration: const Duration(seconds: 2),
|
||||
/// vsync: this,
|
||||
/// )..repeat(reverse: true);
|
||||
/// _animation = CurvedAnimation(
|
||||
/// parent: _controller,
|
||||
/// curve: Curves.easeIn,
|
||||
/// );
|
||||
/// }
|
||||
///
|
||||
/// @override
|
||||
/// void dispose() {
|
||||
/// _controller.dispose();
|
||||
/// super.dispose();
|
||||
/// }
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return Container(
|
||||
/// color: Colors.white,
|
||||
/// child: FadeTransition(
|
||||
/// opacity: _animation,
|
||||
/// child: const Padding(
|
||||
/// padding: EdgeInsets.all(8),
|
||||
/// child: FlutterLogo()
|
||||
/// ),
|
||||
/// ),
|
||||
/// );
|
||||
/// }
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue