mirror of
https://github.com/flutter/samples.git
synced 2026-04-03 02:02:27 +00:00
clean up expand_card demo
This commit is contained in:
@@ -7,17 +7,17 @@ class ExpandCardDemo extends StatelessWidget {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(),
|
appBar: AppBar(),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: SimpleExpandableCard(),
|
child: ExpandCard(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class SimpleExpandableCard extends StatefulWidget {
|
class ExpandCard extends StatefulWidget {
|
||||||
_SimpleExpandableCardState createState() => _SimpleExpandableCardState();
|
_ExpandCardState createState() => _ExpandCardState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SimpleExpandableCardState extends State<SimpleExpandableCard>
|
class _ExpandCardState extends State<ExpandCard>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
static const Duration duration = Duration(milliseconds: 300);
|
static const Duration duration = Duration(milliseconds: 300);
|
||||||
bool expanded = false;
|
bool expanded = false;
|
||||||
@@ -42,36 +42,18 @@ class _SimpleExpandableCardState extends State<SimpleExpandableCard>
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
duration: duration,
|
duration: duration,
|
||||||
crossFadeState:
|
crossFadeState:
|
||||||
expanded ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
expanded ? CrossFadeState.showSecond : CrossFadeState.showFirst,
|
||||||
firstChild: _ImageContainer(
|
firstChild: AnimatedContainer(
|
||||||
size: size, image: 'assets/wolf.jpg', duration: duration),
|
duration: duration,
|
||||||
secondChild: _ImageContainer(
|
width: size,
|
||||||
size: size, image: 'assets/cat.jpg', duration: duration),
|
height: size,
|
||||||
),
|
child: Image.asset('assets/cat.jpg', fit: BoxFit.cover,),
|
||||||
),
|
),
|
||||||
);
|
secondChild: AnimatedContainer(
|
||||||
}
|
duration: duration,
|
||||||
}
|
width: size,
|
||||||
|
height: size,
|
||||||
class _ImageContainer extends StatelessWidget {
|
child: Image.asset('assets/wolf.jpg', fit: BoxFit.cover,),
|
||||||
final double size;
|
|
||||||
final String image;
|
|
||||||
final Duration duration;
|
|
||||||
|
|
||||||
_ImageContainer({this.size, this.image, this.duration});
|
|
||||||
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: AnimatedContainer(
|
|
||||||
duration: duration,
|
|
||||||
width: size,
|
|
||||||
height: size,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.transparent,
|
|
||||||
image: DecorationImage(
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
image: AssetImage(image),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user