showSliderDialog function
void
showSliderDialog({})
Shows a slider dialog for selecting a value.
Implementation
void showSliderDialog({
required BuildContext context, // Build context for the dialog
required String title, // Title of the dialog
required int divisions, // Number of divisions for the slider
required double min, // Minimum value for the slider
required double max, // Maximum value for the slider
String valueSuffix = '', // Suffix to display with the value
required double value, // Initial value of the slider
required Stream<double> stream, // Stream to provide slider values
required ValueChanged<double> onChanged, // Callback for value change
}) {
// final bool isDarkMode = Theme.of(context).brightness == Brightness.dark;
// final Color iconColor = isDarkMode ? Colors.white : Colors.black;
showDialog<void>(
context: context,
builder: (context) => AlertDialog(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
title: Text(title, textAlign: TextAlign.center), // Dialog title
content: StreamBuilder<double>(
stream: stream, // Stream to listen for value changes
builder: (context, snapshot) => SizedBox(
height: 100.0, // Height of the dialog content
child: Column(
children: [
// Display the current value with the specified suffix
Text('${snapshot.data?.toStringAsFixed(1)}$valueSuffix',
style: TextStyle(
fontFamily: 'Fixed', // Font family
color: Theme.of(context).primaryColor,
fontWeight: FontWeight.bold, // Font weight
fontSize: 24.0,),), // Font size
Slider(
divisions: divisions, // Number of divisions for the slider
min: min, // Minimum value for the slider
max: max, // Maximum value for the slider
value: snapshot.data ??
value, // Current value from the stream or initial value
onChanged: onChanged, // Callback for value change
),
],
),
),
),
),
);
}