Unverified Commit c0675577 authored by ny927's avatar ny927 Committed by GitHub

Add sample code to RelativePositionedTransition (#63940)

parent 23e1d8f3
......@@ -924,6 +924,61 @@ class PositionedTransition extends AnimatedWidget {
/// animated by a [CurvedAnimation] set to [Curves.elasticInOut]:
/// {@animation 300 378 https://flutter.github.io/assets-for-api-docs/assets/widgets/relative_positioned_transition.mp4}
///
/// {@tool dartpad --template=stateful_widget_material_ticker}
///
/// The following code implements the [RelativePositionedTransition] 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: [
/// RelativePositionedTransition(
/// size: biggest,
/// rect: RectTween(
/// begin: Rect.fromLTWH(0, 0, bigLogo, bigLogo),
/// end: Rect.fromLTWH(biggest.width - smallLogo, biggest.height - smallLogo, smallLogo, smallLogo),
/// ).animate(CurvedAnimation(
/// parent: _controller,
/// curve: Curves.elasticInOut,
/// )),
/// child: Padding(
/// padding: const EdgeInsets.all(8),
/// child: FlutterLogo()
/// ),
/// ),
/// ],
/// );
/// },
/// );
/// }
/// ```
/// {@end-tool}
///
/// See also:
///
/// * [PositionedTransition], a widget that animates its child from a start
......
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