1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-08 16:06:40 +00:00

clean up expand_card demo

This commit is contained in:
John Ryan
2019-07-12 10:59:24 -07:00
parent 05e0e71f73
commit 5ec0857864

View File

@@ -1,13 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ExpandCardDemo extends StatelessWidget { class ExpandCardDemo extends StatelessWidget {
static String routeName = '/simple_expandable_card'; static String routeName = '/expand_card';
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(),
title: Text('Simple Expandable Card'),
),
body: Center( body: Center(
child: SimpleExpandableCard(), child: SimpleExpandableCard(),
), ),
@@ -24,21 +22,21 @@ class _SimpleExpandableCardState extends State<SimpleExpandableCard>
static const Duration duration = Duration(milliseconds: 300); static const Duration duration = Duration(milliseconds: 300);
bool expanded = false; bool expanded = false;
double get size => expanded ? 200 : 100;
void initState() { void initState() {
super.initState(); super.initState();
} }
void _toggleExpanded() { void toggleExpanded() {
setState(() { setState(() {
expanded = !expanded; expanded = !expanded;
}); });
} }
double get size => expanded ? 200 : 100;
Widget build(context) { Widget build(context) {
return GestureDetector( return GestureDetector(
onTap: () => _toggleExpanded(), onTap: () => toggleExpanded(),
child: Card( child: Card(
child: AnimatedCrossFade( child: AnimatedCrossFade(
alignment: Alignment.center, alignment: Alignment.center,