mirror of
https://github.com/flutter/samples.git
synced 2026-04-01 17:23:18 +00:00
swap AnimatedContainer and AnimatedCrossFade
This commit is contained in:
@@ -34,27 +34,43 @@ class _ExpandCardState extends State<ExpandCard>
|
|||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => toggleExpanded(),
|
onTap: () => toggleExpanded(),
|
||||||
child: Card(
|
child: Card(
|
||||||
child: AnimatedCrossFade(
|
child: Padding(
|
||||||
alignment: Alignment.center,
|
padding: const EdgeInsets.all(8.0),
|
||||||
duration: duration,
|
child: AnimatedContainer(
|
||||||
crossFadeState:
|
|
||||||
expanded ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
|
||||||
firstChild: AnimatedContainer(
|
|
||||||
duration: duration,
|
duration: duration,
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
child: Image.asset(
|
child: AnimatedCrossFade(
|
||||||
'assets/cat.jpg',
|
duration: duration,
|
||||||
fit: BoxFit.cover,
|
crossFadeState: expanded
|
||||||
),
|
? CrossFadeState.showSecond
|
||||||
),
|
: CrossFadeState.showFirst,
|
||||||
secondChild: AnimatedContainer(
|
// Use Positioned.fill() to pass the constraints to its children.
|
||||||
duration: duration,
|
// This allows the Images to use BoxFit.cover to cover the correct
|
||||||
width: size,
|
// size
|
||||||
height: size,
|
layoutBuilder: (Widget topChild, Key topChildKey,
|
||||||
child: Image.asset(
|
Widget bottomChild, Key bottomChildKey) {
|
||||||
'assets/wolf.jpg',
|
return Stack(
|
||||||
fit: BoxFit.cover,
|
children: <Widget>[
|
||||||
|
Positioned.fill(
|
||||||
|
key: bottomChildKey,
|
||||||
|
child: bottomChild,
|
||||||
|
),
|
||||||
|
Positioned.fill(
|
||||||
|
key: topChildKey,
|
||||||
|
child: topChild,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
firstChild: Image.asset(
|
||||||
|
'assets/cat.jpg',
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
secondChild: Image.asset(
|
||||||
|
'assets/wolf.jpg',
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user