我刚刚做了一个颤振项目。如何使一个可扩展为主然后内容可以根据我们所说的改变
我的意思是这样的:
main () {
body: column [
myMasterExpand (mycontent1 ()),
myMasterExpand (mycontent2 ()),
];
}
class myMasterExpand () {}
class mycontent1 () {}
class mycontent2 () {}
我刚刚做了一个颤振项目。如何使一个可扩展为主然后内容可以根据我们所说的改变
我的意思是这样的:
main () {
body: column [
myMasterExpand (mycontent1 ()),
myMasterExpand (mycontent2 ()),
];
}
class myMasterExpand () {}
class mycontent1 () {}
class mycontent2 () {}
您可以创建一个像这样的小部件作为您的主人:
class MyMasterExpandable extends StatelessWidget {
final String title;
final Widget content;
const MyMasterExpandable({Key key, @required this.title, @required this.content})
: super(key: key);
@override
Widget build(BuildContext context) {
return ExpansionTile(
title: Text(title),
children: [content],
);
}
}
这可以像这样使用:
MyMasterExpandable(title: 'My Title', content: content1);