gpt4 book ai didi

Flutter:如何从 ExpansionPanelList 中删除高程?

转载 作者:行者123 更新时间:2023-12-03 13:30:55 27 4
gpt4 key购买 nike

我试图像小部件一样列出下拉列表,但幸运的是找到了扩展面板列表小部件来获得我想要的用户体验。

所以,我在我的 flutter 应用程序中使用 ExpansionPanelList,但不需要它附带的默认高程/边框阴影。

我不知道如何移除它,以便让它看起来是 body 的一部分,而不是一个高架容器。

目前看起来像这样:

mock

以下是我的代码:

class _PracticetestComp extends State<Practicetest> {
var listofpracticetest;
List<Item> _data = [
Item(
headerValue: 'Previous Question Papers',
expandedValue: '',
)
];


@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xffF8FDF7),
appBar: AppBar(
backgroundColor: Color(0xffF8FDF7), // status bar color
brightness: Brightness.light,
elevation: 0.0,
leading: Container(
margin: EdgeInsets.only(left: 17),
child: RawMaterialButton(
onPressed: () {
Navigator.pushNamed(context, '/');
},
child: new Icon(
Icons.keyboard_backspace,
color: Colors.red[900],
size: 25.0,
),
shape: new CircleBorder(),
elevation: 4.0,
fillColor: Colors.white,
padding: const EdgeInsets.all(5.0),
),
),
),
body: Container(
// height: 200,
margin: EdgeInsets.only(top: 40),
child: ListView(
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[

Container(
margin: EdgeInsets.only(top: 30),
child: Theme(
data: Theme.of(context)
.copyWith(cardColor: Color(0xffF8FDF7)),
child: _buildPanelPreviousPapers()))
],
)
],
),
));
}

Widget _buildPanelPreviousPapers() {
return ExpansionPanelList(
expansionCallback: (int index, bool isExpanded) {
setState(() {
_data[index].isExpanded = !isExpanded;
});
},
children: _data.map<ExpansionPanel>((Item item) {
return ExpansionPanel(
headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile(
title: Text(item.headerValue),
);
},
body: Container(

child: ListTile(
leading: Text(
'Alegbra',
style:
TextStyle(color: Colors.black, fontWeight: FontWeight.w500),
),

),
),
),
isExpanded: item.isExpanded,
);
}).toList(),
);
}
}

// stores ExpansionPanel state information
class Item {
Item({
this.expandedValue,
this.headerValue,
this.isExpanded = false,
});

String expandedValue;
String headerValue;
bool isExpanded;
}

最佳答案

将整个扩展小部件子组件包裹在 中 Material 小部件 并根据扩展子项是否使用方法扩展来更改高程

   Material(
elevation: isSelected ? 4 : 0,
child: ExpansionTile(
onExpansionChanged:(value){
isSelected=value;
setState(){};
},

title: getExpantionTitle(context),
children: getChildrentList(),
),
),
),

如果您不喜欢 ExpansionTile 瓷砖中的分隔线,请执行以下操作
        final theme = Theme.of(context).copyWith(dividerColor: 
Colors.transparent);
//use as a child
child:Theme(data: theme, child: ExpansionTile(...));

关于Flutter:如何从 ExpansionPanelList 中删除高程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60463999/

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