在下面这个颤动的ExpansionPanelList
小部件中,我试图将白色背景着色为其他颜色,例如indigo
,我找不到任何文档或有用的链接来实现这一目标
ExpansionPanelList(
expansionCallback: (int index, bool isExpanded) {
setState(() {
_categoryExpansionStateMap[_categoryExpansionStateMap.keys
.toList()[index]] = !isExpanded;
});
},
children: <ExpansionPanel>[
ExpansionPanel(
headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile(
contentPadding: EdgeInsets.all(3.0),
leading: Container(
padding:
EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0),
decoration: BoxDecoration(
border: Border(
left: BorderSide(
width: 3.0, color: Colors.white54))),
child: Icon(
Icons.account_circle,
size: 30.0,
color: Colors.black,
),
),
title: ListTile(
contentPadding: EdgeInsets.all(0.0),
title: Text(
Strings.yourBasicInformation,
style: TextStyle(
color: Colors.black,
fontSize: 14.0,),
)
),
);
},
body: Biography(),
isExpanded: _categoryExpansionStateMap["Biography"]),
],
),
答案 0 :(得分:1)
您可以尝试两个动作。一。将您的ExpansionPanelList
包裹在Container
中并在Container
中传递颜色,我认为它应该可以工作,我不知道其余的代码。
第二步,将ExpansionPanelList
包裹在Theme
组件中。传递数据,然后调用ThemeData().copyWith(canvasColor: Colors.white)
。然后,它看起来像这样:
Theme(
data: ThemeData().copyWith(canvasColor: Colors.white),
child: ExpansionPanelList(
expansionCallback: (int index, bool isExpanded) {
setState(() {
_categoryExpansionStateMap[_categoryExpansionStateMap.keys
.toList()[index]] = !isExpanded;
});
},
children: <ExpansionPanel>[
ExpansionPanel(
headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile(
contentPadding: EdgeInsets.all(3.0),
leading: Container(
padding:
EdgeInsets.fromLTRB(10.0, 0.0, 10.0, 0.0),
decoration: BoxDecoration(
border: Border(
left: BorderSide(
width: 3.0, color: Colors.white54))),
child: Icon(
Icons.account_circle,
size: 30.0,
color: Colors.black,
),
),
title: ListTile(
contentPadding: EdgeInsets.all(0.0),
title: Text(
Strings.yourBasicInformation,
style: TextStyle(
color: Colors.black,
fontSize: 14.0,),
)
),
);
},
body: Biography(),
isExpanded: _categoryExpansionStateMap["Biography"]),
],
),
)