Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I just made a flutter project. how to make one expandable as master then the content can change according to what we call

enter image description here

what I mean is something like this:

main () {
body: column [
myMasterExpand (mycontent1 ()),
myMasterExpand (mycontent2 ()),
];
}

class myMasterExpand () {}

class mycontent1 () {}
class mycontent2 () {}
question from:https://stackoverflow.com/questions/65660539/how-to-make-one-widget-as-master-in-flutter

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
203 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can create a widget like this as your master:

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],
    );
  }
}

This can be used like this:

MyMasterExpandable(title: 'My Title', content: content1);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...