return ListView.builder( physics: const NeverScrollableScrollPhysics(), shrinkWrap:…
- User
return 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)], ); }); }
TableRow tableRow(index) { double topBorder = index != 0 ? 1.w : 3.w; double bottomBorder = index != widget.firstHandsets!.specifications!.length - 1 ? 1.w : 4.w; return TableRow( decoration: BoxDecoration( border: Border( top: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: topBorder), bottom: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: bottomBorder), right: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w), left: BorderSide( color: UIColors.aluminium, style: BorderStyle.solid, width: 3.w), )), children: [ Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( height: 5.h, ), if (index == 0) sectionTitle('{widget.firstHandsets?.specifications?[index].specification?.label}') ], ), ), specificationsDetails(index, '{widget.secondHandsets?.specifications?[index].description}'), specificationsDetails(index, '${widget.thirdHandsets?.specifications?[index].description}'), ], );} i want to add fixed row before this row contains some constants texts
- Assistant
To add a fixed row before the dynamic row, you can wrap the
ListView.builderwith aColumnwidget and place the fixed row as the first child of theColumn. Here's an example:dartColumn( children: [ // Fixed row Table( // Table properties children: [ TableRow( // TableRow properties children: [ // Fixed row cells TableCell( child: Text('Fixed Content 1'), ), TableCell( child: Text('Fixed Content 2'), ), TableCell( child: Text('Fixed Content 3'), ), TableCell( child: Text('Fixed Content 4'), ), ], ), ], ), // Dynamic row ListView.builder( // Listview properties physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: widget.firstHandsets?.specifications?.length ?? 0, itemBuilder: (context, index) { return Table( // Table properties children: [tableRow(index)], ); }, ), ], ) - User
there is ubnormal behavior , the fixed row duplicated!
- Assistant
I apologize for the confusion. To avoid duplication of the fixed row, you can move the fixed row outside the
ListView.builderand include it as a separateTableRowwithin the widget. Here's an updated example: - User
still the fixed row dublicated after each row in tableRow(index)
- Assistant
- User
not fixed
- Assistant