我可以正常创建并显示ExpansionPanelList.radio
。它的children
属性包含ExpansionPanelRadio
个项目的列表。它可以正常工作-除了一件事:
当我导航至其他标签,然后返回包含我的ExpansionPanelList.radio
的标签时,先前展开的ExpansionPanelRadio
项现在被折叠。
我希望能够保留最后一个扩展的ExpansionPanelRadio
的扩展名,但是它的isExpanded
属性是只读的。与ExpansionPanel
不同,ExpansionPanelRadio
并未在其构造函数中定义isExpanded
。
关于如何实现此目标的任何想法? 谢谢!
编辑:为清楚起见,这是显示EpxpansionPalnelList.radio
的代码:
class ProductsByApplicationWidget extends StatelessWidget {
final ProductsByApplication productsByApplication;
final int indexOfExpandedFieldOfApplication;
const ProductsByApplicationWidget(
{Key key,@required this.productsByApplication,@required this.indexOfExpandedFieldOfApplication})
: assert(productsByApplication != null),assert(indexOfExpandedFieldOfApplication != null),super(key: key);
@override
Widget build(BuildContext context) {
return Container(
child: _buildPanel(),);
}
Widget _buildPanel() {
return ExpansionPanelList.radio(
animationDuration: Duration(milliseconds: 300),children:
productsByApplication.productsForApplicationList
.map<ExpansionPanel>((ProductsForApplication productsForApplication) {
return ExpansionPanelRadio(
canTapOnHeader: true,headerBuilder: (BuildContext context,bool isExpanded) {
return FieldOfApplicationHeaderCellWidget(application: productsForApplication.application,);
},body: Container(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),child: Column(
children:
productsForApplication.products.map<ProductCellWidget>((Product product) {
return ProductCellWidget(product: product);
}).toList(),),value: productsForApplication.application.id,);
}).toList(),);
}
}