ListDataTileStyle.of constructor
ListDataTileStyle.of(
- BuildContext context, {
- Color? backgroundColor,
- Color? foregroundColor,
- Color? evenBackgroundColor,
- Color? evenForegroundColor,
- Color? hoverBackgroundColor,
- Color? evenHoverBackgroundColor,
- SelectedTileColor? selectedColor,
- TextStyle? textStyle,
- Widget? trailingIcon,
- bool? withCheckboxIcon,
- Widget? checkboxIcon,
- Widget? selectedCheckboxIcon,
A factory method that creates a ListDataTileStyle object with default values taken from the given BuildContext.
The parameters of this method are as follows:
backgroundColor: the background color of the list tile. Defaults to Colors.transparent.foregroundColor: the foreground color of the list tile. Defaults to Theme.of(context).colorScheme.onSurface.evenBackgroundColor: the background color of the list tile at even indices. Defaults to Theme.of(context).colorScheme.onSurface with 30% opacity.evenForegroundColor: the foreground color of the list tile at even indices. Defaults toforegroundColorif not null, or Theme.of(context).colorScheme.onSurface if null.hoverBackgroundColor: the background color of the list tile when hovered. Defaults to Theme.of(context).colorScheme.primary with 50% opacity.evenHoverBackgroundColor: the background color of the list tile at even indices when hovered. Defaults tohoverBackgroundColorif not null, or Theme.of(context).colorScheme.primary with 100% opacity if null.selectedColor: the color of the selected list tile. Defaults to SelectedTileColor.of(context).textStyle: the text style of the list tile. Defaults to null.trailingIcon: the trailing icon of the list tile. Defaults to null.withCheckboxIcon: whether to show the checkbox icon of the list tile. Defaults to true.checkboxIcon: the checkbox icon of the list tile. Defaults to null.selectedCheckboxIcon: the selected checkbox icon of the list tile. Defaults to null.
Implementation
factory ListDataTileStyle.of(
BuildContext context, {
Color? backgroundColor,
Color? foregroundColor,
Color? evenBackgroundColor,
Color? evenForegroundColor,
Color? hoverBackgroundColor,
Color? evenHoverBackgroundColor,
SelectedTileColor? selectedColor,
TextStyle? textStyle,
Widget? trailingIcon,
bool? withCheckboxIcon,
Widget? checkboxIcon,
Widget? selectedCheckboxIcon,
}) {
var isDark = Theme.of(context).brightness == Brightness.dark;
return ListDataTileStyle(
backgroundColor: backgroundColor ?? Colors.transparent,
foregroundColor:
foregroundColor ?? Theme.of(context).colorScheme.onSurface,
evenBackgroundColor:
evenBackgroundColor ??
(isDark ? Color(0xFF1E1E1E) : Color(0xFFE0E0E0)),
evenForegroundColor:
evenForegroundColor ??
foregroundColor ??
Theme.of(context).colorScheme.onSurface,
hoverBackgroundColor:
hoverBackgroundColor ??
(isDark ? Color(0xFF2A3A4F) : Color(0xFFE3F2FD)),
evenHoverBackgroundColor:
evenHoverBackgroundColor ??
(isDark ? Color(0xFF243447) : Color(0xFFD0EBFF)),
selectedColor: selectedColor ?? SelectedTileColor.of(context),
textStyle: textStyle,
trailingIcon: trailingIcon,
withCheckboxIcon: withCheckboxIcon ?? true,
checkboxIcon: checkboxIcon,
selectedCheckboxIcon: selectedCheckboxIcon,
);
}