import 'package:flutter/material.dart'; import 'board.dart'; import 'paper.dart'; /// The exact solved symbol becomes the illustration, and stays on the page. class Discovery extends StatefulWidget { const Discovery({ super.key, required this.picture, required this.label, required this.artwork, required this.height, }); final List picture; final String label; final Widget artwork; final double height; @override State createState() => _DiscoveryState(); } class _DiscoveryState extends State with SingleTickerProviderStateMixin { late final AnimationController _animation = AnimationController( vsync: this, duration: const Duration(milliseconds: 2800), ); @override void didChangeDependencies() { super.didChangeDependencies(); if (MediaQuery.disableAnimationsOf(context)) { _animation.value = 1; } else if (_animation.isDismissed) { _animation.forward(); } } @override void dispose() { _animation.dispose(); super.dispose(); } @override Widget build(BuildContext context) => Column( children: [ AnimatedBuilder( animation: _animation, builder: (context, _) { final art = const Interval( .3, .85, curve: Curves.easeInOut, ).transform(_animation.value); final pattern = 1 - const Interval( .45, .95, curve: Curves.easeInOut, ).transform(_animation.value); return SizedBox( height: widget.height, child: Stack( alignment: Alignment.center, children: [ Opacity(opacity: art, child: widget.artwork), ExcludeSemantics( child: Opacity( opacity: pattern, child: PatternStamp( widget.picture, label: widget.label, height: widget.height, ), ), ), ], ), ); }, ), const SizedBox(height: 10), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ PatternStamp(widget.picture, label: widget.label, height: 56), const SizedBox(width: 14), Flexible( child: Text( 'Your restored pattern\n${widget.label}', style: hand(18, color: muted), ), ), ], ), if (!MediaQuery.disableAnimationsOf(context)) InkButton( 'See the transformation again', () => _animation.forward(from: 0), size: 18, ), ], ); }