getDualTableRows method

TableRow getDualTableRows(
  1. Map<dynamic, Map<String, String>> item,
  2. Map<dynamic, Map<String, String>>? secondItem, {
  3. double firstItemPadding = 4.0,
  4. double secondItemPadding = 4.0,
  5. double secondItemLeftPadding = 15.0,
  6. Color firstItemIconColor = Colors.black,
  7. Color firstItemTitleColor = Colors.black,
  8. Color secondItemTitleColor = Colors.black,
  9. Color firstItemValueColor = Colors.black,
  10. Color secondItemValueColor = Colors.black,
  11. Color secondItemIconColor = Colors.black,
})

Creates a table row with two complex items containing icons/images and text.

Generates a TableRow with two cells, each containing an icon or network image along with title and value text. Supports both IconData and network image URLs.

Parameters:

  • item: Map where key is icon/image URL and value contains title-value pairs.
  • secondItem: Optional map for the second column with same structure.
  • firstItemPadding: Padding around first item content (defaults to 4.0).
  • secondItemPadding: Padding around second item content (defaults to 4.0).
  • secondItemLeftPadding: Left padding for second column (defaults to 15.0).
  • firstItemIconColor: Color for first item's icon (defaults to black).
  • firstItemTitleColor: Color for first item's title (defaults to black).
  • secondItemTitleColor: Color for second item's title (defaults to black).
  • firstItemValueColor: Color for first item's value (defaults to black).
  • secondItemValueColor: Color for second item's value (defaults to black).
  • secondItemIconColor: Color for second item's icon (defaults to black).

Returns a TableRow with complex formatted cells.

The map structure should be:

{
  Icons.person or 'https://image.url': {
    'Title': 'Value'
  }
}

Example:

getDualTableRows(
  {Icons.email: {'Email': 'user@example.com'}},
  {Icons.phone: {'Phone': '+1234567890'}},
  firstItemIconColor: Colors.blue,
  secondItemIconColor: Colors.green,
);

Implementation

TableRow getDualTableRows(Map<dynamic, Map<String, String>> item,
    Map<dynamic, Map<String, String>>? secondItem,
    {double firstItemPadding = 4.0,
    double secondItemPadding = 4.0,
    double secondItemLeftPadding = 15.0,
    Color firstItemIconColor = Colors.black,
    Color firstItemTitleColor = Colors.black,
    Color secondItemTitleColor = Colors.black,
    Color firstItemValueColor = Colors.black,
    Color secondItemValueColor = Colors.black,
    Color secondItemIconColor = Colors.black}) {
  return TableRow(
    children: [
      Row(
        children: [
          (item.keys.first is IconData)
              ? Padding(
                  padding: const EdgeInsets.only(left: 10),
                  child: Icon(
                    item.keys.first,
                    color: firstItemIconColor,
                  ),
                )
              : item.keys.first.toString().isNotEmpty
                  ? Padding(
                      padding: const EdgeInsets.only(left: 13, right: 2),
                      child: SizedBox(
                        width: 20,
                        child: getRoundedNetworkImage(item),
                      ),
                    )
                  : Container(),
          Expanded(
            child: Padding(
              padding: EdgeInsets.all(firstItemPadding),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  item.values.first.keys.first.isNotEmpty
                      ? Utils.commonWidgets.setText(
                          item.values.first.keys.first,
                          Utils.appConstants.boldFontFamily,
                          firstItemTitleColor,
                          Utils.appConstants.normalFontSize)
                      : Container(),
                  item.values.first.values.first.isNotEmpty
                      ? Utils.commonWidgets.setText(
                          item.values.first.values.first,
                          Utils.appConstants.boldFontFamily,
                          firstItemValueColor,
                          Utils.appConstants.normalFontSize)
                      : Container(),
                ],
              ),
            ),
          )
        ],
      ),
      secondItem != null
          ? Padding(
              padding: EdgeInsets.fromLTRB(secondItemLeftPadding, 0, 0, 0),
              child: Row(
                children: [
                  (secondItem.keys.first is IconData)
                      ? SizedBox(
                          width: 25,
                          child: Icon(
                            secondItem.keys.first,
                            color: secondItemIconColor,
                          ),
                        )
                      : secondItem.keys.first.toString().isNotEmpty
                          ? Padding(
                              padding:
                                  const EdgeInsets.only(left: 4.5, right: 2),
                              child: SizedBox(
                                width: 20,
                                child: getRoundedNetworkImage(secondItem),
                              ),
                            )
                          : Container(),
                  Expanded(
                    child: Padding(
                      padding: EdgeInsets.all(secondItemPadding),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          secondItem.values.first.keys.first.isNotEmpty
                              ? Utils.commonWidgets.setText(
                                  secondItem.values.first.keys.first,
                                  Utils.appConstants.boldFontFamily,
                                  secondItemTitleColor,
                                  Utils.appConstants.normalFontSize)
                              : Container(),
                          secondItem.values.first.values.first.isNotEmpty
                              ? Utils.commonWidgets.setText(
                                  secondItem.values.first.values.first,
                                  Utils.appConstants.boldFontFamily,
                                  secondItemValueColor,
                                  Utils.appConstants.normalFontSize)
                              : Container(),
                        ],
                      ),
                    ),
                  )
                ],
              ),
            )
          : Container()
    ],
  );
}