uiListTile method

Widget uiListTile({
  1. required void onTap(),
  2. Key? key,
  3. bool enabled = true,
  4. dynamic leading,
  5. Widget? title,
  6. Widget? subtitle,
  7. dynamic trailing,
  8. ListTileThemeData? style,
})

Creates a selectable widget to be part of a view of selectable items.

Implementation

Widget uiListTile({
  required void Function() onTap,
  Key? key,
  bool enabled = true,
  dynamic leading,
  Widget? title,
  Widget? subtitle,
  dynamic trailing,
  ListTileThemeData? style,
}) {
  // Make sure we are using things properly
  assert(
    leading is IconData || leading is Image || leading == null,
    "leading can only be an Image, IconData, or null type",
  );
  assert(
    trailing is IconData || trailing is Image || trailing == null,
    "trailing can only be an Image, IconData, or null type",
  );

  // Create a return the widget.
  final w = ListTile(
    key: key,
    leading: leading is IconData ? Icon(leading) : leading,
    title: title,
    subtitle: subtitle,
    trailing: trailing is IconData ? Icon(trailing) : trailing,
    onTap: enabled ? onTap : null,
  );

  return style != null
      ? ListTileTheme(
          key: key,
          data: style,
          child: w,
        )
      : w;
}