final List<Widget> enterprises = _wEnterpriseList ..retainWhere((wEnterprise) =>…
- User
final List enterprises = _wEnterpriseList ..retainWhere((wEnterprise) => wEnterprise.e.unhidden) ..map( (wEnterprise) => Material( elevation: 2, child: wEnterprise, ), ).toList();
- Assistant
This code snippet creates a new list called
enterprisesbased on the_wEnterpriseListlist. It performs two operations on the elements of the list:-
It uses the
retainWheremethod to keep only the elements that satisfy the conditionwEnterprise.e.unhidden. This means that only thewEnterpriseinstances with theunhiddenproperty set totruewill be kept in theenterpriseslist. -
It uses the
mapmethod to transform each remainingwEnterpriseelement into aMaterialwidget, with an elevation of 2. TheMaterialwidget wraps thewEnterpriseelement.
Finally, the
toListmethod is called to convert the resulting iterable into a list and assign it to theenterprisesvariable. -
- User
..retainWhere((wEnterprise) => wEnterprise.e.unhidden) ..map( (wEnterprise) => Material( elevation: 2, child: wEnterprise, ), ).toList(); ``` - Assistant
This code snippet creates a new list called
enterprisesby performing the following operations on the_wEnterpriseListlist:-
It uses the
retainWheremethod to filter the list, keeping only the elements that satisfy the conditionwEnterprise.e.unhidden. This means that only thewEnterpriseinstances with theunhiddenproperty set totruewill remain in theenterpriseslist. -
It uses the
mapmethod to transform each remainingwEnterpriseelement into aMaterialwidget. TheMaterialwidget has an elevation of 2 and its child is set to the correspondingwEnterpriseinstance.
Finally, the
toListmethod is called to convert the resulting iterable into a list, which is then assigned to theenterprisesvariable. -