Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child:…
- User
Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: TableCell( child: Padding( padding: const EdgeInsets.all(8.0), child: Text( '${firstHandsets?.price ?? " "}' + (firstHandsets?.price != null ? " " + "currency.egyptianPound".tr() : ""), style: TextStyle( fontWeight: FontWeight.w400, fontSize: 24.sp, color: UIColors.darkGrey)), ), ), ),Another exception was thrown: Incorrect use of ParentDataWidget.
- Assistant
The error "Another exception was thrown: Incorrect use of ParentDataWidget" suggests that there is an issue with how the
Paddingwidget is being used as a child of aTableCell.To fix this issue, you can try removing the
Paddingwidget and directly apply the padding to theTextwidget. Here's an example:TableCell( child: Padding( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: Text( '${firstHandsets?.price ?? " "}' + (firstHandsets?.price != null ? " " + "currency.egyptianPound".tr() : ""), style: TextStyle( fontWeight: FontWeight.w400, fontSize: 24.sp, color: UIColors.darkGrey, ), // Apply padding directly to the Text widget textAlign: TextAlign.center, softWrap: true, ), ), ),Make sure to adjust the padding values according to your desired layout. Keep in mind that the
TableCellwidget can only have one direct child, so be mindful of the widget hierarchy when making changes.If the issue persists, please provide more of your code or the complete error message for further assistance.
- User
well but no i want to leave padding before text in table cell without this exception
- Assistant
If you want to add padding around the
Textwidget inside theTableCellwithout getting the "Incorrect use of ParentDataWidget" exception, you can use theContainerwidget instead ofPadding.Here's an updated code snippet that adds the desired padding:
TableCell( child: Container( padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 2.h), child: Text( '${firstHandsets?.price ?? " "}' + (firstHandsets?.price != null ? " " + "currency.egyptianPound".tr() : ""), style: TextStyle( fontWeight: FontWeight.w400, fontSize: 24.sp, color: UIColors.darkGrey, ), ), ), ),By wrapping the
Textwidget with aContainerand applying the padding to it, you can achieve the desired padding without triggering the "Incorrect use of ParentDataWidget" exception.Let me know if this solves the issue for you.