Unverified Commit e13b44d9 authored by Hansol Lee's avatar Hansol Lee Committed by GitHub

Add sample code to PositionedTransition (#59156)

parent 8cf15ee2
......@@ -724,6 +724,60 @@ class RelativeRectTween extends Tween<RelativeRect> {
/// animated by a [CurvedAnimation] set to [Curves.elasticInOut]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/positioned_transition.mp4}
///
/// {@tool dartpad --template=stateful_widget_material_ticker}
///
/// The following code implements the [PositionedTransition] as seen in the video
/// above:
///
/// ```dart
/// AnimationController _controller;
///
/// @override
/// void initState() {
/// super.initState();
/// _controller = AnimationController(
/// duration: const Duration(seconds: 2),
/// vsync: this,
/// )..repeat(reverse: true);
/// }
///
/// @override
/// void dispose() {
/// _controller.dispose();
/// super.dispose();
/// }
///
/// @override
/// Widget build(BuildContext context) {
/// final double smallLogo = 100;
/// final double bigLogo = 200;
///
/// return LayoutBuilder(
/// builder: (context, constraints) {
/// final Size biggest = constraints.biggest;
/// return Stack(
/// children: [
/// PositionedTransition(
/// rect: RelativeRectTween(
/// begin: RelativeRect.fromSize(Rect.fromLTWH(0, 0, smallLogo, smallLogo), biggest),
/// end: RelativeRect.fromSize(Rect.fromLTWH(biggest.width - bigLogo, biggest.height - bigLogo, bigLogo, bigLogo), biggest),
/// ).animate(CurvedAnimation(
/// parent: _controller,
/// curve: Curves.elasticInOut,
/// )),
/// child: Padding(
/// padding: const EdgeInsets.all(8),
/// child: FlutterLogo()
/// ),
/// ),
/// ],
/// );
/// },
/// );
/// }
/// ```
/// {@end-tool}
///
/// See also:
///
/// * [AnimatedPositioned], which transitions a child's position without
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment