Add Sample code to SlideTransition (#41009)
This commit is contained in:
committed by
GitHub
parent
43932aa2ca
commit
81e693a7fe
@@ -194,6 +194,51 @@ class _AnimatedState extends State<AnimatedWidget> {
|
||||
/// animated by a [CurvedAnimation] set to [Curves.elasticIn]:
|
||||
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/slide_transition.mp4}
|
||||
///
|
||||
/// {@tool snippet --template=stateful_widget_scaffold_center_freeform_state}
|
||||
/// The following code implements the [SlideTransition] as seen in the video
|
||||
/// above:
|
||||
///
|
||||
/// ```dart
|
||||
/// class _MyStatefulWidgetState extends State<MyStatefulWidget> with SingleTickerProviderStateMixin {
|
||||
/// AnimationController _controller;
|
||||
/// Animation<Offset> _offsetAnimation;
|
||||
///
|
||||
/// @override
|
||||
/// void initState() {
|
||||
/// super.initState();
|
||||
/// _controller = AnimationController(
|
||||
/// duration: const Duration(seconds: 2),
|
||||
/// vsync: this,
|
||||
/// )..repeat(reverse: true);
|
||||
/// _offsetAnimation = Tween<Offset>(
|
||||
/// begin: Offset.zero,
|
||||
/// end: const Offset(1.5, 0.0),
|
||||
/// ).animate(CurvedAnimation(
|
||||
/// parent: _controller,
|
||||
/// curve: Curves.elasticIn,
|
||||
/// ));
|
||||
/// }
|
||||
///
|
||||
/// @override
|
||||
/// void dispose() {
|
||||
/// super.dispose();
|
||||
/// _controller.dispose();
|
||||
/// }
|
||||
///
|
||||
/// @override
|
||||
/// Widget build(BuildContext context) {
|
||||
/// return SlideTransition(
|
||||
/// position: _offsetAnimation,
|
||||
/// child: const Padding(
|
||||
/// padding: EdgeInsets.all(8.0),
|
||||
/// child: FlutterLogo(size: 150.0),
|
||||
/// ),
|
||||
/// );
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [AlignTransition], an animated version of an [Align] that animates its
|
||||
|
||||
Reference in New Issue
Block a user