ScrollbarConfig.preset constructor
Creates a ScrollbarConfig with common preset configurations.
Available presets:
thick
: A thicker scrollbar with enhanced visibilitythin
: A minimal, thin scrollbarrounded
: A scrollbar with rounded cornershidden
: A completely hidden scrollbar
Implementation
factory ScrollbarConfig.preset({required String preset, Color? color}) {
final effectiveColor = color ?? Colors.blue;
switch (preset.toLowerCase()) {
case 'thick':
return ScrollbarConfig(
visible: true,
themeData: ScrollbarThemeData(
thickness: WidgetStateProperty.all(12.0),
thumbColor: WidgetStateProperty.all(effectiveColor),
trackColor: WidgetStateProperty.all(
effectiveColor.withValues(alpha: 0.2),
),
radius: const Radius.circular(6.0),
thumbVisibility: WidgetStateProperty.all(true),
trackVisibility: WidgetStateProperty.all(true),
),
);
case 'thin':
return ScrollbarConfig(
visible: true,
themeData: ScrollbarThemeData(
thickness: WidgetStateProperty.all(4.0),
thumbColor: WidgetStateProperty.all(
effectiveColor.withValues(alpha: 0.8),
),
trackColor: WidgetStateProperty.all(Colors.transparent),
radius: const Radius.circular(2.0),
thumbVisibility: WidgetStateProperty.all(false),
trackVisibility: WidgetStateProperty.all(false),
),
);
case 'rounded':
return ScrollbarConfig(
visible: true,
themeData: ScrollbarThemeData(
thickness: WidgetStateProperty.all(8.0),
thumbColor: WidgetStateProperty.all(effectiveColor),
trackColor: WidgetStateProperty.all(
effectiveColor.withValues(alpha: 0.15),
),
radius: const Radius.circular(12.0),
thumbVisibility: WidgetStateProperty.all(true),
trackVisibility: WidgetStateProperty.all(true),
),
);
case 'hidden':
return const ScrollbarConfig(visible: false);
default:
return ScrollbarConfig(
visible: true,
themeData: ScrollbarThemeData(
thickness: WidgetStateProperty.all(6.0),
thumbColor: WidgetStateProperty.all(
effectiveColor.withValues(alpha: 0.7),
),
trackColor: WidgetStateProperty.all(
Colors.grey.withValues(alpha: 0.3),
),
radius: const Radius.circular(3.0),
),
);
}
}