Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. var items = [];
  2.  
  3. Widget buildExpansionList() {
  4. if (items.length == 0) {
  5. "Nunquam anhelare ionicis tormento est regius abnoba"
  6. .split(" ")
  7. .forEach((t) {
  8. items.add({
  9. "title": t,
  10. "expanded": false,
  11. "color": Colors.green,
  12. });
  13. });
  14. }
  15. return SingleChildScrollView(
  16. child: ExpansionPanelList(
  17. expansionCallback: (int index, bool isExpanded) {
  18. setState(() {
  19. items[index]["expanded"] = !items[index]["expanded"];
  20. });
  21. },
  22. children: items.map((item) {
  23. return ExpansionPanel(
  24. isExpanded: item["expanded"],
  25. headerBuilder: (BuildContext context, bool isExpanded) {
  26. return Text(
  27. item["title"],
  28. style: Theme.of(context).textTheme.display1,
  29. );
  30. },
  31. body: Container(
  32. width: double.infinity,
  33. color: item["color"].withOpacity(0.4),
  34. child: IconButton(
  35. iconSize: 64.0,
  36. color: item["color"],
  37. icon: Icon(Icons.colorize),
  38. onPressed: () {
  39. setState(() {
  40. item["color"] = (item["color"] == Colors.red
  41. ? Colors.green
  42. : Colors.red);
  43. });
  44. },
  45. ),
  46. ),
  47. );
  48. }).toList(),
  49. ),
  50. );
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement