Skip to content

Instantly share code, notes, and snippets.

@Ahmadre
Created June 18, 2020 01:54
Show Gist options
  • Save Ahmadre/4b06dbb935279ec7be8e5adfa9282e46 to your computer and use it in GitHub Desktop.
Save Ahmadre/4b06dbb935279ec7be8e5adfa9282e46 to your computer and use it in GitHub Desktop.
Naive example for Expanding Child inside ExpansionTile
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
final kExpansionTileHeight = 114;
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
ExpansionTile(
title: Text('Expand me'),
children: [
SizedBox(
height:
MediaQuery.of(context).size.height - kExpansionTileHeight,
child: IntrinsicHeight(
child: Container(
alignment: Alignment.center,
color: Colors.blue.shade500,
child: Text("I'm expanded!"),
),
),
),
],
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment