return Column( children: [ Table( border: TableBorder.symmetric( inside: BorderSide(…
- User
return Column( children: [ Table( border: TableBorder.symmetric( inside: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 2.w), ), children: [ TableRow( decoration: BoxDecoration( border: Border( top: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w), bottom: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w), right: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w), left: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w), )), children: [ // Fixed row cells Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( height: 5.h, ), sectionTitle('Price'), SizedBox( height: 7.h, ), specificationsType('Price'), ], ), ),
Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: TableCell( child: specificationsDetails(0, '300'), ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: TableCell( child: specificationsDetails(0, '300'), ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: TableCell( child: specificationsDetails(0, '300'), ), ), ]) ]), ListView.builder( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: widget.firstHandsets?.specifications?.length ?? 0, itemBuilder: (context, index) { return Table( border: TableBorder.symmetric( inside: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 2.w), ), children: [tableRow(index)], ); }, ), ], );} this code duplicate the first row many times i just want it to show one at the top
- Assistant
To have only one first row at the top, you can remove the
ListView.builderand directly add theTablewithtableRow(index)method inside theColumnwidget. Here's the updated code:return Column( children: [ Table( border: TableBorder.symmetric( inside: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 2.w, ), ), children: [ TableRow( decoration: BoxDecoration( border: Border( top: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w, ), bottom: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w, ), right: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w, ), left: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w, ), ), ), children: [ // Fixed row cells Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox(height: 5.h), sectionTitle('Price'), SizedBox(height: 7.h), specificationsType('Price'), ], ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: TableCell( child: specificationsDetails(0, '300'), ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: TableCell( child: specificationsDetails(0, '300'), ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: TableCell( child: specificationsDetails(0, '300'), ), ), ], ), ], ), Table( border: TableBorder.symmetric( inside: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 2.w, ), ), children: [ tableRow(0), ], ), ], );This will display the first row only at the top, and the subsequent rows will be shown as per the
tableRowmethod for each index. - User
no i want to remian the dynamic row as it and just show the fixed row once at top
- Assistant
I apologize for the misunderstanding. In that case, you can keep the
ListView.builderand modify the code to conditionally show the fixed row at the top. Here's the updated code:return Column( children: [ Table( border: TableBorder.symmetric( inside: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 2.w, ), ), children: [ if (widget.firstHandsets?.specifications?.isNotEmpty ?? false) TableRow( decoration: BoxDecoration( border: Border( top: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w, ), bottom: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w, ), right: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w, ), left: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w, ), ), ), children: [ // Fixed row cells Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox(height: 5.h), sectionTitle('Price'), SizedBox(height: 7.h), specificationsType('Price'), ], ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: TableCell( child: specificationsDetails(0, '300'), ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: TableCell( child: specificationsDetails(0, '300'), ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: TableCell( child: specificationsDetails(0, '300'), ), ), ], ), ], ), ListView.builder( physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: widget.firstHandsets?.specifications?.length ?? 0, itemBuilder: (context, index) { return Table( border: TableBorder.symmetric( inside: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 2.w, ), ), children: [tableRow(index)], ); }, ), ], );Now, the fixed row will only be shown at the top if
widget.firstHandsets.specificationsis not empty. The dynamic rows below it will be displayed based onListView.builderas before.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.