cardListTile static method

Widget cardListTile(
  1. IconData icon,
  2. Color iconColor,
  3. String title, {
  4. String subtitle = "",
  5. void onTap()?,
  6. Widget? trailing = const Icon(CupertinoIcons.right_chevron),
})

Implementation

static Widget cardListTile(IconData icon, Color iconColor, String title,
    {String subtitle = "",
    void Function()? onTap,
    Widget? trailing = const Icon(CupertinoIcons.right_chevron)}) {
  var iconSize = 24.0;

  if (subtitle.isEmpty) {
    iconSize = 18.0;
  }

  var tile2 = ListTile(
    leading: Container(
      padding: const EdgeInsets.all(5),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(50),
        color: iconColor,
      ),
      child: Icon(
        icon,
        size: iconSize,
        color: Colors.white,
      ),
    ),
    title: Text(
      title,
      style: const TextStyle(
        fontSize: 16,
      ),
    ),
    subtitle: subtitle.isNotEmpty ? Text(subtitle) : null,
    trailing: trailing,
    dense: true,
    onTap: onTap,
    minLeadingWidth: 12,
  );

  return Container(
    margin: EdgeInsets.symmetric(vertical: 2),
    decoration: BoxDecoration(
      border: Border.all(
        color: Color(
            0xAACCCCCC), // You can change the color to your desired color
        width: 1.0, // You can adjust the width of the border
      ),
    ),
    child: Card(
      color: Colors.white,
      elevation: 0,
      child: tile2,
    ),
  );
}