import 'package:flutter/material.dart';
import 'expansion_tile_demo.dart';
main(){
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData.dark(),
home: ExpansionTileDemo()
);
}
}
import 'package:flutter/material.dart';
class ExpansionTileDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Expansion Tile Demo')),
body: Center(
child: ExpansionTile(
title: Text('Expansion Tile '),
// 放开始的组件
leading: Icon(Icons.ac_unit),
// 设置点开后的背景颜色
backgroundColor: Colors.white24,
// 设置展开显示的内容
children: <Widget>[
ListTile(
title: Text('List title'),
subtitle: Text('Subtitle'),
)
],
// 第一次显示打开的状态
//initiallyExpanded: true,
),
),
);
}
}