gpt4 book ai didi

Flutter 着色背景 ExpansionPanelList

转载 作者:IT王子 更新时间:2023-10-29 07:19:23 28 4
gpt4 key购买 nike

在下面的 flutter 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"]),
],
),

最佳答案

您可以尝试两个 Action 。一。将你的 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"]),
],
),
)

关于Flutter 着色背景 ExpansionPanelList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56349416/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com