Skip to content

Commit 28f311a

Browse files
authored
[Documentation] Add AlignTransition interactive example (flutter#87021)
1 parent 3391c7e commit 28f311a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

packages/flutter/lib/src/widgets/transitions.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,48 @@ class DecoratedBoxTransition extends AnimatedWidget {
12081208
///
12091209
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/align_transition.mp4}
12101210
///
1211+
/// {@tool dartpad --template=stateful_widget_material_ticker}
1212+
/// The following code implements the [AlignTransition] as seen in the video
1213+
/// above:
1214+
///
1215+
/// ```dart
1216+
/// // Using `late final` for [lazy initialization](https://dart.dev/null-safety/understanding-null-safety#lazy-initialization).
1217+
/// late final AnimationController _controller = AnimationController(
1218+
/// duration: const Duration(seconds: 2),
1219+
/// vsync: this,
1220+
/// )..repeat(reverse: true);
1221+
/// late final Animation<AlignmentGeometry> _animation = Tween<AlignmentGeometry>(
1222+
/// begin: Alignment.bottomLeft,
1223+
/// end: Alignment.center,
1224+
/// ).animate(
1225+
/// CurvedAnimation(
1226+
/// parent: _controller,
1227+
/// curve: Curves.decelerate,
1228+
/// ),
1229+
/// );
1230+
///
1231+
/// @override
1232+
/// void dispose() {
1233+
/// _controller.dispose();
1234+
/// super.dispose();
1235+
/// }
1236+
///
1237+
/// @override
1238+
/// Widget build(BuildContext context) {
1239+
/// return Container(
1240+
/// color: Colors.white,
1241+
/// child: AlignTransition(
1242+
/// alignment: _animation,
1243+
/// child: const Padding(
1244+
/// padding: EdgeInsets.all(8),
1245+
/// child: FlutterLogo(size: 150.0),
1246+
/// ),
1247+
/// ),
1248+
/// );
1249+
/// }
1250+
/// ```
1251+
/// {@end-tool}
1252+
///
12111253
/// See also:
12121254
///
12131255
/// * [AnimatedAlign], which animates changes to the [alignment] without

0 commit comments

Comments
 (0)