### Complete Price Range Selector Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/event-callbacks.md Demonstrates a complete Flutter widget that uses FlutterSlider to allow users to select a price range. It includes callbacks for drag start, dragging, and drag completion to update the UI and apply filters. ```dart class PriceRangeSelector extends StatefulWidget { @override _PriceRangeSelectorState createState() => _PriceRangeSelectorState(); } class _PriceRangeSelectorState extends State { double _minPrice = 100; double _maxPrice = 500; bool _isAdjusting = false; @override Widget build(BuildContext context) { return Column( children: [ Text('Price Range: No results found. ``` -------------------------------- ### Feature-Rich Slider Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/00-START-HERE.md An advanced example showcasing various customization options including steps, tooltips, track bars, and handler animations. Suitable for complex UI requirements. ```dart FlutterSlider( values: [300], max: 500, min: 0, step: FlutterSliderStep(step: 10), tooltip: FlutterSliderTooltip( format: (value) => ' ${value.toStringAsFixed(0)}', ), trackBar: FlutterSliderTrackBar( activeTrackBar: BoxDecoration(color: Colors.blue), ), handlerAnimation: FlutterSliderHandlerAnimation( scale: 1.5, ), ) ``` -------------------------------- ### Example Usage of FlutterSliderHatchMarkLabel Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/types.md Provides an example of how to define labels for hatch marks at specific percentages along the slider. This demonstrates setting labels for the 0%, 50%, and 100% marks. ```dart [ FlutterSliderHatchMarkLabel(percent: 0, label: Text('0')), FlutterSliderHatchMarkLabel(percent: 50, label: Text('50%')), FlutterSliderHatchMarkLabel(percent: 100, label: Text('100')), ] ``` -------------------------------- ### Price Range Filter Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/quick-start.md Implement a price range filter for e-commerce applications. This example uses a range slider to select minimum and maximum prices. ```dart class PriceRangeFilter extends StatefulWidget { @override _PriceRangeFilterState createState() => _PriceRangeFilterState(); } class _PriceRangeFilterState extends State { double _minPrice = 100; double _maxPrice = 900; @override Widget build(BuildContext context) { return Column( children: [ Text( 'Price: \$${_minPrice.toStringAsFixed(0)} - \$${_maxPrice.toStringAsFixed(0)}', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), SizedBox(height: 20), FlutterSlider( values: [_minPrice, _maxPrice], min: 0, max: 1000, rangeSlider: true, step: FlutterSliderStep(step: 10), tooltip: FlutterSliderTooltip( format: (value) => '\$${value.toStringAsFixed(0)}', alwaysShowTooltip: false, ), onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _minPrice = lowerValue; _maxPrice = upperValue; }); }, ), SizedBox(height: 20), ElevatedButton( onPressed: () => _applyFilter(_minPrice, _maxPrice), child: Text('Apply Filter'), ), ], ); } void _applyFilter(double minPrice, double maxPrice) { print('Filtering products: \$$minPrice - \$$maxPrice'); } } ``` -------------------------------- ### Vertical Slider Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/flutter-slider-widget.md Demonstrates how to display the FlutterSlider in a vertical orientation. ```dart FlutterSlider( values: [250], max: 500, min: 0, axis: Axis.vertical, onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _selectedValue = lowerValue; }); }, ) ``` -------------------------------- ### Advanced Flutter Slider Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md This example demonstrates a fully customized Flutter Slider with advanced features like handler animations, custom tooltips, styled track bars, and hatch marks with labels. It's useful for creating price range selectors or any slider requiring detailed visual feedback and control. ```dart class AdvancedSliderExample extends StatefulWidget { @override _AdvancedSliderExampleState createState() => _AdvancedSliderExampleState(); } class _AdvancedSliderExampleState extends State { double _price = 300; bool _isFiltering = false; @override Widget build(BuildContext context) { return FlutterSlider( values: [_price], min: 0, max: 1000, handlerAnimation: FlutterSliderHandlerAnimation( curve: Curves.elasticOut, reverseCurve: Curves.bounceIn, duration: Duration(milliseconds: 500), scale: 1.5, ), tooltip: FlutterSliderTooltip( textStyle: TextStyle(color: Colors.white, fontSize: 16), boxStyle: FlutterSliderTooltipBox( decoration: BoxDecoration( color: Colors.blue.withOpacity(0.9), borderRadius: BorderRadius.circular(6), ), ), format: (value) => '${value.toStringAsFixed(0)}', alwaysShowTooltip: false, ), trackBar: FlutterSliderTrackBar( activeTrackBar: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(4), ), inactiveTrackBar: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.circular(4), ), ), hatchMark: FlutterSliderHatchMark( displayLines: true, density: 0.5, labels: [ FlutterSliderHatchMarkLabel(percent: 0, label: Text('$0')), FlutterSliderHatchMarkLabel(percent: 50, label: Text('$500')), FlutterSliderHatchMarkLabel(percent: 100, label: Text('$1000')), ], ), step: FlutterSliderStep(step: 10), onDragStarted: (handlerIndex, lowerValue, upperValue) { setState(() => _isFiltering = true); }, onDragging: (handlerIndex, lowerValue, upperValue) { setState(() => _price = lowerValue); }, onDragCompleted: (handlerIndex, lowerValue, upperValue) { setState(() => _isFiltering = false); _applyFilter(lowerValue); }, ); } void _applyFilter(double price) { print('Filter by price: ${price}'); } } ``` -------------------------------- ### Stepped Slider Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/quick-start.md Configure a slider to jump between discrete values with specified increments. Use 'jump: true' to enable stepping. ```dart FlutterSlider( values: [50], max: 100, min: 0, step: FlutterSliderStep(step: 10), // Increments of 10 jump: true, // Jump to steps instead of smooth drag onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _value = lowerValue; }); }, ) ``` -------------------------------- ### Full Flutter Slider Configuration Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/configuration.md Provides a comprehensive example showcasing all available configuration options for the Flutter Slider, including range, handlers, interaction, stepping, constraints, track, tooltip, hatch marks, styling, and callbacks. ```dart FlutterSlider( // Range values: [100, 400], min: 0, max: 500, // Mode rangeSlider: true, axis: Axis.horizontal, rtl: false, // Handlers handlerWidth: 40, handlerHeight: 40, handler: FlutterSliderHandler( decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.blue, ), ), rightHandler: FlutterSliderHandler( decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.green, ), ), handlerAnimation: FlutterSliderHandlerAnimation( scale: 1.4, curve: Curves.elasticOut, ), // Interaction selectByTap: true, touchSize: 20, disabled: false, // Stepping step: FlutterSliderStep(step: 10), jump: false, // Constraints minimumDistance: 50, maximumDistance: 400, // Track trackBar: FlutterSliderTrackBar( activeTrackBar: BoxDecoration(color: Colors.blue), inactiveTrackBar: BoxDecoration(color: Colors.grey), activeTrackBarHeight: 5, inactiveTrackBarHeight: 3, ), // Tooltip tooltip: FlutterSliderTooltip( textStyle: TextStyle(color: Colors.white), alwaysShowTooltip: false, ), // Hatch marks hatchMark: FlutterSliderHatchMark( displayLines: true, density: 0.5, ), // Styling decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8), ), // Callbacks onDragStarted: (handlerIndex, lowerValue, upperValue) {}, onDragging: (handlerIndex, lowerValue, upperValue) {}, onDragCompleted: (handlerIndex, lowerValue, upperValue) {}, ) ``` -------------------------------- ### Add Dependency to pubspec.yaml Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/quick-start.md Add the `another_xlider` package to your project's `pubspec.yaml` file and run `flutter pub get` to install it. ```yaml dependencies: flutter: sdk: flutter another_xlider: ^3.0.0 ``` -------------------------------- ### Minimal Flutter Slider Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/README.md Basic setup for a single-value Flutter Slider. ```dart FlutterSlider( values: [300], max: 500, min: 0, ) ``` -------------------------------- ### Basic Range Slider Example Source: https://github.com/loonix/another_xlider/blob/master/README.md Demonstrates a FlutterSlider configured as a range slider with two selectable values. Ideal for selecting a range of values. ```dart FlutterSlider( values: [30, 420], rangeSlider: true, max: 500, min: 0, onDragging: (handlerIndex, lowerValue, upperValue) { _lowerValue = lowerValue; _upperValue = upperValue; setState(() {}); }, ) ``` -------------------------------- ### Range Slider Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/README.md Configures a Flutter Slider for selecting a range of values. Includes an `onDragging` callback to update state. ```dart FlutterSlider( values: [100, 400], min: 0, max: 500, rangeSlider: true, onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _minValue = lowerValue; _maxValue = upperValue; }); }, ) ``` -------------------------------- ### Basic Range Slider Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/quick-start.md Create a slider with two handlers to select a range of values. The `rangeSlider` property must be set to `true`, and `onDragging` updates both lower and upper values. ```dart import 'package:flutter/material.dart'; import 'package:another_xlider/another_xlider.dart'; class RangeSliderExample extends StatefulWidget { @override _RangeSliderExampleState createState() => _RangeSliderExampleState(); } class _RangeSliderExampleState extends State { double _lowerValue = 100; double _upperValue = 400; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Range Slider')), body: Padding(padding: EdgeInsets.all(16), child: Column( children: [ Text('Range: $_lowerValue - $_upperValue'), FlutterSlider( values: [_lowerValue, _upperValue], max: 500, min: 0, rangeSlider: true, onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _lowerValue = lowerValue; _upperValue = upperValue; }); }, ), ], ), ), ); } } ``` -------------------------------- ### Basic Single Slider Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/quick-start.md Implement a simple slider with a single handler for selecting a value within a defined range. The `onDragging` callback updates the state with the selected value. ```dart import 'package:flutter/material.dart'; import 'package:another_xlider/another_xlider.dart'; class SingleSliderExample extends StatefulWidget { @override _SingleSliderExampleState createState() => _SingleSliderExampleState(); } class _SingleSliderExampleState extends State { double _value = 300; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Single Slider')), body: Padding(padding: EdgeInsets.all(16), child: Column( children: [ Text('Selected: $_value'), FlutterSlider( values: [_value], max: 500, min: 0, onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _value = lowerValue; }); }, ), ], ), ), ); } } ``` -------------------------------- ### onDragStarted Callback Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/event-callbacks.md Fires once when the user begins dragging a handler. Useful for initiating visual feedback or logging interaction start. ```APIDOC ## onDragStarted ### Description Fires once when the user begins dragging a handler. This callback is suitable for initiating visual feedback, starting animations, or logging analytics events. ### Parameters - **handlerIndex** (int) - Identifies which handler triggered the event (0 for left/single, 1 for right in range mode). - **lowerValue** (dynamic) - The current lower selected value. Its type depends on the slider configuration (numeric, custom, or formatted). - **upperValue** (dynamic) - The current upper selected value. Its type is the same as lowerValue. ### Example Usage ```dart FlutterSlider( values: [300], max: 500, min: 0, onDragStarted: (handlerIndex, lowerValue, upperValue) { print('Drag started'); print('Handler: $handlerIndex'); print('Lower: $lowerValue, Upper: $upperValue'); }, ) ``` ``` -------------------------------- ### Single Slider Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/flutter-slider-widget.md Basic usage of FlutterSlider for selecting a single value within a defined range. ```dart FlutterSlider( values: [300], max: 500, min: 0, onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _selectedValue = lowerValue; }); }, ) ``` -------------------------------- ### Temperature Slider with Centered Origin Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md A temperature slider example using `centeredOrigin` where the active track color changes based on the selected temperature relative to the center. ```dart FlutterSlider( values: [50], // 50 degrees, centered at 50 min: 0, max: 100, centeredOrigin: true, trackBar: FlutterSliderTrackBar( activeTrackBar: BoxDecoration( color: (selectedTemp > 50) ? Colors.red : Colors.blue, ), ), onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { selectedTemp = lowerValue; }); }, ) ``` -------------------------------- ### FlutterSliderIgnoreSteps Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/types.md Defines ranges of values on the slider that should be ignored and cannot be selected by the user. Useful for preventing selection of specific intervals. ```dart [ FlutterSliderIgnoreSteps(from: 8000, to: 12000), FlutterSliderIgnoreSteps(from: 18000, to: 22000), ] ``` -------------------------------- ### Business Hours Slider Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Example of using ignoreSteps to represent business hours, preventing selection during night hours. ```dart FlutterSlider( values: [9], max: 24, min: 0, step: FlutterSliderStep(step: 1), ignoreSteps: [ FlutterSliderIgnoreSteps(from: 0, to: 6), // Midnight-6am FlutterSliderIgnoreSteps(from: 19, to: 24), // 7pm-midnight ], ) ``` -------------------------------- ### FlutterSlider onDragStarted Callback Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/event-callbacks.md Fires once when the user begins dragging a handler. Use this to show tooltips, start animations, or log analytics. ```dart FlutterSlider( values: [300], max: 500, min: 0, onDragStarted: (handlerIndex, lowerValue, upperValue) { print('Drag started'); print('Handler: $handlerIndex'); print('Lower: $lowerValue, Upper: $upperValue'); }, ) ``` -------------------------------- ### Basic Centered Origin Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Starts selection from the center of the slider and expands outward for single-value sliders. The active track extends from the center to the selected value. ```dart FlutterSlider( values: [250], min: 0, max: 500, centeredOrigin: true, trackBar: FlutterSliderTrackBar( activeTrackBar: BoxDecoration(color: Colors.blue), ), ) ``` -------------------------------- ### Time Range Picker with Flutter Slider Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/quick-start.md Implement a time range picker using FlutterSlider to select start and end times. The slider displays custom tooltips showing the selected time in AM/PM format. ```dart class TimeRangePicker extends StatefulWidget { @override _TimeRangePickerState createState() => _TimeRangePickerState(); } class _TimeRangePickerState extends State { double _startTime = 9; // 9 AM double _endTime = 17; // 5 PM String _timeString(double hour) { int h = hour.toInt(); String ampm = h >= 12 ? 'PM' : 'AM'; int displayHour = h > 12 ? h - 12 : h; return '$displayHour:00 $ampm'; } @override Widget build(BuildContext context) { return Column( children: [ Text( 'Work Hours: ${_timeString(_startTime)} - ${_timeString(_endTime)}', style: TextStyle(fontSize: 16), ), SizedBox(height: 20), FlutterSlider( values: [_startTime, _endTime], min: 0, max: 24, rangeSlider: true, step: FlutterSliderStep(step: 1), tooltip: FlutterSliderTooltip( custom: (value) { return Text(_timeString(value)); }, ), onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _startTime = lowerValue; _endTime = upperValue; }); }, ), ], ); } } ``` -------------------------------- ### Basic Handler Animation Configuration Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Configure basic handler animation properties like curve, duration, and scale. ```dart FlutterSlider( values: [300], max: 500, min: 0, handlerAnimation: FlutterSliderHandlerAnimation( curve: Curves.elasticOut, reverseCurve: Curves.bounceIn, duration: Duration(milliseconds: 500), scale: 1.5, ), ) ``` -------------------------------- ### Use Custom Tooltip Widget Source: https://github.com/loonix/another_xlider/blob/master/README.md Replace the default tooltip with a fully custom widget by using the `custom` function. This provides maximum flexibility in tooltip design. ```dart FlutterSlider( ... tooltip: FlutterSliderTooltip( custom: (value) { return Text(value.toString()); } ), ... ) ``` -------------------------------- ### Hatch Marks Slider Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/README.md Adds hatch marks and labels to the slider for visual guidance, including start and end labels. ```dart FlutterSlider( values: [500000], max: 1000000, min: 0, hatchMark: FlutterSliderHatchMark( displayLines: true, density: 0.5, labels: [ FlutterSliderHatchMarkLabel(percent: 0, label: Text('0')), FlutterSliderHatchMarkLabel(percent: 100, label: Text('1M')), ], ), ) ``` -------------------------------- ### Price Range Filter Slider Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/README.md Sets up a range slider for a price filter with custom step increments and formatted tooltips. ```dart FlutterSlider( values: [100, 900], min: 0, max: 1000, rangeSlider: true, step: FlutterSliderStep(step: 10), tooltip: FlutterSliderTooltip( format: (value) => '$${value.toStringAsFixed(0)}', ), ) ``` -------------------------------- ### Add Prefix and Suffix to Tooltip Source: https://github.com/loonix/another_xlider/blob/master/README.md Add widgets like icons before or after the tooltip's value using `leftPrefix`, `leftSuffix`, `rightPrefix`, and `rightSuffix`. This is useful for adding currency symbols or other indicators. ```dart FlutterSlider( ... tooltip: FlutterSliderTooltip( leftPrefix: Icon(Icons.attach_money, size: 19, color: Colors.black45,), rightSuffix: Icon(Icons.attach_money, size: 19, color: Colors.black45,), ), ... ) ``` -------------------------------- ### Tooltip with Prefix and Suffix Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Adds icons as prefixes and suffixes to the tooltip values. Useful for indicating units or types. ```dart FlutterSlider( values: [30, 420], max: 500, min: 0, rangeSlider: true, tooltip: FlutterSliderTooltip( leftPrefix: Icon(Icons.attach_money, size: 19), rightSuffix: Icon(Icons.attach_money, size: 19), format: (value) => value.toStringAsFixed(0), ), ) ``` -------------------------------- ### Import Paths for Another XLider Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/INDEX.md This snippet lists the essential import statements required to use the main widget and various configuration models and enumerations from the Another XLider package. ```dart // Main widget import 'package:another_xlider/another_xlider.dart'; // Configuration models import 'package:another_xlider/models/handler.dart'; import 'package:another_xlider/models/handler_animation.dart'; import 'package:another_xlider/models/trackbar.dart'; import 'package:another_xlider/models/slider_step.dart'; import 'package:another_xlider/models/range_step.dart'; import 'package:another_xlider/models/fixed_value.dart'; import 'package:another_xlider/models/ignore_steps.dart'; import 'package:another_xlider/models/hatch_mark.dart'; import 'package:another_xlider/models/hatch_mark_label.dart'; import 'package:another_xlider/models/tooltip/tooltip.dart'; import 'package:another_xlider/models/tooltip/tooltip_box.dart'; import 'package:another_xlider/models/tooltip/tooltip_position_offset.dart'; // Enumerations import 'package:another_xlider/enums/tooltip_direction_enum.dart'; import 'package:another_xlider/enums/hatch_mark_alignment_enum.dart'; ``` -------------------------------- ### Defer Expensive Work to Next Frame Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/event-callbacks.md Optimize performance by updating the UI immediately and deferring expensive calculations to the next frame using `WidgetsBinding.instance.addPostFrameCallback`. This prevents the UI from freezing during intensive computations. ```dart void _onSliderDrag(int handlerIndex, dynamic lowerValue, dynamic upperValue) { // Update UI immediately setState(() { _selectedValue = lowerValue; }); // Defer expensive work to next frame WidgetsBinding.instance.addPostFrameCallback((_) { _expensiveCalculation(lowerValue); }); } ``` -------------------------------- ### FlutterSliderFixedValue Example Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/types.md Maps specific percentage positions on the slider to custom, non-numeric values. Useful for creating categorical sliders or sliders with descriptive labels at certain points. ```dart [ FlutterSliderFixedValue(percent: 0, value: "Very Low"), FlutterSliderFixedValue(percent: 25, value: "Low"), FlutterSliderFixedValue(percent: 50, value: "Medium"), FlutterSliderFixedValue(percent: 75, value: "High"), FlutterSliderFixedValue(percent: 100, value: "Very High"), ] ``` -------------------------------- ### Custom Tooltip Widget Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Replaces the default tooltip with a fully custom widget. Allows for rich UI elements within the tooltip. ```dart FlutterSlider( values: [300], max: 500, min: 0, tooltip: FlutterSliderTooltip( custom: (value) { return Container( padding: EdgeInsets.all(8), decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(8), ), child: Text( 'Price: \$${value.toStringAsFixed(0)}', style: TextStyle(color: Colors.white), ), ); }, ), ) ``` -------------------------------- ### Conditional Handler Customization Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/quick-start.md Customize the slider's handler appearance dynamically based on the current slider value. This example changes the handler's background color. ```dart FlutterSlider( values: [_value], max: 500, min: 0, handler: _value < 250 ? FlutterSliderHandler( decoration: BoxDecoration(color: Colors.red), ) : FlutterSliderHandler( decoration: BoxDecoration(color: Colors.green), ), ) ``` -------------------------------- ### Another XLider File Structure Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/INDEX.md This snippet outlines the directory and file organization within the Another XLider package, showing the location of the main widget, models, enums, and helper widgets. ```tree lib/ ├── another_xlider.dart # Main widget ├── models/ │ ├── handler.dart # FlutterSliderHandler │ ├── handler_animation.dart # FlutterSliderHandlerAnimation │ ├── trackbar.dart # FlutterSliderTrackBar │ ├── slider_step.dart # FlutterSliderStep │ ├── range_step.dart # FlutterSliderRangeStep │ ├── fixed_value.dart # FlutterSliderFixedValue │ ├── ignore_steps.dart # FlutterSliderIgnoreSteps │ ├── hatch_mark.dart # FlutterSliderHatchMark │ ├── hatch_mark_label.dart # FlutterSliderHatchMarkLabel │ └── tooltip/ │ ├── tooltip.dart # FlutterSliderTooltip │ ├── tooltip_box.dart # FlutterSliderTooltipBox │ └── tooltip_position_offset.dart # FlutterSliderTooltipPositionOffset ├── enums/ │ ├── tooltip_direction_enum.dart # FlutterSliderTooltipDirection │ └── hatch_mark_alignment_enum.dart # FlutterSliderHatchMarkAlignment └── widgets/ ├── make_handler.dart # MakeHandler widget builder └── sized_box.dart # FlutterSliderSizedBox ``` -------------------------------- ### Callback Parameters Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/README.md Defines the signature for all callback parameters, including handler index and the lower/upper selected values. ```dart void Function(int handlerIndex, dynamic lowerValue, dynamic upperValue) ``` -------------------------------- ### Displaying Hatch Marks with Labels Source: https://github.com/loonix/another_xlider/blob/master/README.md Configure hatch marks with custom density and labels at specific percentages. Use this to visually indicate key points or ranges on the slider track. ```dart FlutterSlider( ... hatchMark: FlutterSliderHatchMark( density: 0.5, // means 50 lines, from 0 to 100 percent labels: [ FlutterSliderHatchMarkLabel(percent: 0, label: Text('Start')), FlutterSliderHatchMarkLabel(percent: 10, label: Text('10,000')), FlutterSliderHatchMarkLabel(percent: 50, label: Text('50 %')), FlutterSliderHatchMarkLabel(percent: 80, label: Text('80,000')), FlutterSliderHatchMarkLabel(percent: 100, label: Text('Finish')), ], ), ... ) ``` -------------------------------- ### Conditionally Update State Based on Value Change Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/event-callbacks.md Implement conditional updates within event handlers to avoid unnecessary state rebuilds. This example only triggers a state update if the slider's value has changed by a significant amount (e.g., 10 units). ```dart void _onSliderDrag(int handlerIndex, dynamic lowerValue, dynamic upperValue) { // Only update if value changed by more than 10 if ((lowerValue - _previousValue).abs() >= 10) { setState(() { _selectedValue = lowerValue; _previousValue = lowerValue; }); } } ``` -------------------------------- ### Debounce Expensive Operations in Callbacks Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/event-callbacks.md Use debouncing to limit the execution of expensive operations within frequently called event handlers like `onDragging`. This snippet cancels any pending timer and starts a new one, ensuring the operation only runs after a brief pause in user interaction. ```dart Timer? _debounceTimer; void _onSliderDrag(int handlerIndex, dynamic lowerValue, dynamic upperValue) { _debounceTimer?.cancel(); _debounceTimer = Timer(Duration(milliseconds: 500), () { // Execute expensive operation after user stops dragging briefly _fetchResultsFromAPI(lowerValue, upperValue); }); } ``` -------------------------------- ### FlutterSlider Constructor Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/flutter-slider-widget.md Initializes a FlutterSlider widget with various configuration options for appearance, behavior, and interaction. ```APIDOC ## FlutterSlider Constructor ### Description Initializes a FlutterSlider widget with various configuration options for appearance, behavior, and interaction. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Constructor Signature ```dart FlutterSlider({ Key? key, this.min, this.max, required this.values, this.fixedValues, this.axis = Axis.horizontal, this.handler, this.rightHandler, this.handlerHeight, this.handlerWidth, this.onDragStarted, this.onDragCompleted, this.onDragging, this.rangeSlider = false, this.rtl = false, this.jump = false, this.ignoreSteps = const [], this.disabled = false, this.touchSize, this.visibleTouchArea = false, this.minimumDistance = 0, this.maximumDistance = 0, this.tooltip, this.trackBar = const FlutterSliderTrackBar(), this.handlerAnimation = const FlutterSliderHandlerAnimation(), this.selectByTap = true, this.step = const FlutterSliderStep(), this.hatchMark, this.centeredOrigin = false, this.lockHandlers = false, this.lockDistance, this.decoration, this.foregroundDecoration, this.containerHeightFactor = 2, }) ``` ### Properties | Property | Type | Required | Default | Description | |----------|------|----------|---------|-------------| | `axis` | `Axis` | No | `Axis.horizontal` | Direction of slider: horizontal or vertical | | `handlerWidth` | `double?` | No | `35` (or matches handlerHeight) | Width of the handler thumb | | `handlerHeight` | `double?` | No | `35` (or matches handlerWidth) | Height of the handler thumb | | `handler` | `FlutterSliderHandler?` | No | — | Left handler customization (range slider only) | | `rightHandler` | `FlutterSliderHandler?` | No | — | Right handler customization | | `onDragStarted` | `Function(int, dynamic, dynamic)?` | No | — | Callback when drag begins | | `onDragCompleted` | `Function(int, dynamic, dynamic)?` | No | — | Callback when drag ends | | `onDragging` | `Function(int, dynamic, dynamic)?` | No | — | Callback during dragging | | `min` | `double?` | Conditional | — | Minimum selectable value (required if fixedValues is null) | | `max` | `double?` | Conditional | — | Maximum selectable value (required if fixedValues is null) | | `values` | `List` | Yes | — | Initial slider values: [singleValue] or [lowerValue, upperValue] | | `fixedValues` | `List?` | No | — | Array of fixed discrete values to snap to | | `rangeSlider` | `bool` | No | `false` | Enable two-handler range slider mode | | `rtl` | `bool` | No | `false` | Enable right-to-left text direction | | `jump` | `bool` | No | `false` | Jump between steps instead of smooth dragging | | `selectByTap` | `bool` | No | `true` | Allow selecting values by tapping on track | | `ignoreSteps` | `List` | No | `[]` | Ranges of values that cannot be selected | | `disabled` | `bool` | No | `false` | Disable all slider interaction | | `touchSize` | `double?` | No | `15` | Size of touchable area around handlers (5-50 range) | | `visibleTouchArea` | `bool` | No | `false` | Debug: visualize the touchable area | | `minimumDistance` | `double` | No | `0` | Minimum distance between handlers in range slider | | `maximumDistance` | `double` | No | `0` | Maximum distance between handlers in range slider | | `tooltip` | `FlutterSliderTooltip?` | No | — | Tooltip display configuration | | `trackBar` | `FlutterSliderTrackBar` | No | `FlutterSliderTrackBar()` | Track appearance and behavior | | `handlerAnimation` | `FlutterSliderHandlerAnimation` | No | `FlutterSliderHandlerAnimation()` | Handler scale animation settings | | `step` | `FlutterSliderStep` | No | `FlutterSliderStep()` | Step configuration for value increments | | `hatchMark` | `FlutterSliderHatchMark?` | No | — | Hatch marks and labels on track | | `centeredOrigin` | `bool` | No | `false` | Start slider from center (single slider only) | | `lockHandlers` | `bool` | No | `false` | Keep handlers at fixed distance apart | | `lockDistance` | `double?` | No | — | Distance between locked handlers (required if lockHandlers is true) | | `decoration` | `BoxDecoration?` | No | — | Container background decoration | | `foregroundDecoration` | `BoxDecoration?` | No | — | Container foreground decoration | | `containerHeightFactor` | `double` | No | `2` | Height multiplier for horizontal slider container | ``` -------------------------------- ### Time Range Slider with Hatch Marks Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/configuration.md Implements a time range slider for a 24-hour period (1440 minutes) with custom hatch marks and labels representing hours. The step is set to 15 minutes, and the onDragging callback updates start and end time state variables. ```dart FlutterSlider( values: [25, 75], min: 0, max: 1440, // minutes in a day rangeSlider: true, step: FlutterSliderStep(step: 15), hatchMark: FlutterSliderHatchMark( displayLines: true, density: 0.25, labels: [ FlutterSliderHatchMarkLabel(percent: 0, label: Text('00:00')), FlutterSliderHatchMarkLabel(percent: 25, label: Text('06:00')), FlutterSliderHatchMarkLabel(percent: 50, label: Text('12:00')), FlutterSliderHatchMarkLabel(percent: 75, label: Text('18:00')), FlutterSliderHatchMarkLabel(percent: 100, label: Text('24:00')), ], ), onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _startTime = lowerValue; _endTime = upperValue; }); }, ) ``` -------------------------------- ### Linear Scale Handler Animation Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Configure a linear scale animation for handlers with a short duration. ```dart FlutterSliderHandlerAnimation( curve: Curves.linear, duration: Duration(milliseconds: 200), scale: 1.1, ) ``` -------------------------------- ### FlutterSliderTooltipBox Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/types.md Defines the styling properties for the tooltip container, allowing customization of its background, foreground, and transformations. ```APIDOC ## FlutterSliderTooltipBox ### Description Styling properties for tooltip container. ### Fields - **decoration** (`BoxDecoration?`) - Background decoration for tooltip box - **foregroundDecoration** (`BoxDecoration?`) - Foreground decoration overlay - **transform** (`Matrix4?`) - Transformation matrix applied to tooltip ``` -------------------------------- ### Basic Ignore Steps Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Prevents users from selecting values within specified ranges. Useful for excluding unavailable options. ```dart FlutterSlider( values: [250], max: 25000, min: 0, ignoreSteps: [ FlutterSliderIgnoreSteps(from: 8000, to: 12000), FlutterSliderIgnoreSteps(from: 18000, to: 22000), ], ) ``` -------------------------------- ### Import Another Slider Package Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/quick-start.md Import the `another_xlider` package into your Dart file to use its widgets. ```dart import 'package:another_xlider/another_xlider.dart'; ``` -------------------------------- ### Slider with Tooltips Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/flutter-slider-widget.md Adds customizable tooltips to display the selected value(s) of the slider. ```dart FlutterSlider( values: [300], max: 500, min: 0, tooltip: FlutterSliderTooltip( textStyle: TextStyle(fontSize: 17, color: Colors.white), boxStyle: FlutterSliderTooltipBox( decoration: BoxDecoration( color: Colors.redAccent.withOpacity(0.7), ), ), alwaysShowTooltip: false, ), onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _selectedValue = lowerValue; }); }, ) ``` -------------------------------- ### FlutterSliderTooltip Configuration Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/types.md Configures the display and styling of the tooltip that appears when interacting with the slider. Customize text style, box decoration, value formatting, and visibility. ```dart class FlutterSliderTooltip { Widget Function(dynamic value)? custom; String Function(String value)? format; TextStyle? textStyle; FlutterSliderTooltipBox? boxStyle; Widget? leftPrefix; Widget? leftSuffix; Widget? rightPrefix; Widget? rightSuffix; bool? alwaysShowTooltip; bool? disabled; bool? disableAnimation; FlutterSliderTooltipDirection? direction; FlutterSliderTooltipPositionOffset? positionOffset; FlutterSliderTooltip({ this.custom, this.format, this.textStyle, this.boxStyle, this.leftPrefix, this.leftSuffix, this.rightPrefix, this.rightSuffix, this.alwaysShowTooltip, this.disableAnimation, this.disabled, this.direction, this.positionOffset, }); } ``` ```dart FlutterSliderTooltip( textStyle: TextStyle(fontSize: 17, color: Colors.white), boxStyle: FlutterSliderTooltipBox( decoration: BoxDecoration( color: Colors.blue.withOpacity(0.8), borderRadius: BorderRadius.circular(4), ), ), format: (value) => ' ${value.toStringAsFixed(0)}', alwaysShowTooltip: true, ) ``` -------------------------------- ### Simple Price Range Slider Preset Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/configuration.md Configures a Flutter Slider for a simple price range selection. The tooltip is formatted to display currency, and the onDragging callback updates state variables for minimum and maximum prices. ```dart FlutterSlider( values: [20, 80], min: 0, max: 100, rangeSlider: true, step: FlutterSliderStep(step: 1), tooltip: FlutterSliderTooltip( format: (value) => ' ${(value * 10).toStringAsFixed(0)}', ), onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { _minPrice = lowerValue * 10; _maxPrice = upperValue * 10; }); }, ) ``` -------------------------------- ### Always Show Tooltip Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Configures the tooltip to remain visible at all times, regardless of user interaction. Also shows how to disable animation. ```dart FlutterSlider( values: [300], max: 500, min: 0, tooltip: FlutterSliderTooltip( alwaysShowTooltip: true, disabled: false, disableAnimation: false, ), ) ``` -------------------------------- ### Enable Handler Jump Source: https://github.com/loonix/another_xlider/blob/master/README.md Set `jump` to `true` to make handlers jump between intervals instead of moving fluently. Defaults to `false`. ```dart FlutterSlider( ... jump: true, ... ) ``` -------------------------------- ### Enable Basic Right-to-Left (RTL) Support Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Activate RTL mode for the slider. This is essential for applications supporting languages that read from right to left. ```dart FlutterSlider( values: [300], max: 500, min: 0, rtl: true, ) ``` -------------------------------- ### Range Slider with Callbacks Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/00-START-HERE.md Demonstrates a range slider with two values and an `onDragging` callback to handle user interaction. Useful for selecting a value range. ```dart FlutterSlider( values: [100, 400], min: 0, max: 500, rangeSlider: true, onDragging: (handlerIndex, lowerValue, upperValue) { // Update UI }, ) ``` -------------------------------- ### FlutterSliderTooltip Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/types.md Configures tooltip display when interacting with the slider, including custom formatting, styling, and positioning. ```APIDOC ## FlutterSliderTooltip ### Description Configures tooltip display when interacting with slider. ### Class Signature ```dart class FlutterSliderTooltip { Widget Function(dynamic value)? custom; String Function(String value)? format; TextStyle? textStyle; FlutterSliderTooltipBox? boxStyle; Widget? leftPrefix; Widget? leftSuffix; Widget? rightPrefix; Widget? rightSuffix; bool? alwaysShowTooltip; bool? disabled; bool? disableAnimation; FlutterSliderTooltipDirection? direction; FlutterSliderTooltipPositionOffset? positionOffset; FlutterSliderTooltip({ this.custom, this.format, this.textStyle, this.boxStyle, this.leftPrefix, this.leftSuffix, this.rightPrefix, this.rightSuffix, this.alwaysShowTooltip, this.disableAnimation, this.disabled, this.direction, this.positionOffset, }); } ``` ### Properties | Field | Type | Default | Description | |---|---|---|---| | `custom` | `Widget Function(dynamic)?` | `null` | Custom widget builder for tooltip content | | `format` | `String Function(String)?` | `null` | Function to format value string | | `textStyle` | `TextStyle?` | `null` | Text styling for tooltip | | `boxStyle` | `FlutterSliderTooltipBox?` | `null` | Box decoration and styling | | `leftPrefix` | `Widget?` | `null` | Widget before left tooltip value | | `leftSuffix` | `Widget?` | `null` | Widget after left tooltip value | | `rightPrefix` | `Widget?` | `null` | Widget before right tooltip value | | `rightSuffix` | `Widget?` | `null` | Widget after right tooltip value | | `alwaysShowTooltip` | `bool?` | `false` | Show tooltip even when not dragging | | `disabled` | `bool?` | `false` | Hide tooltip completely | | `disableAnimation` | `bool?` | `false` | Skip animation when showing/hiding | | `direction` | `FlutterSliderTooltipDirection?` | `top` | Position relative to handler | | `positionOffset` | `FlutterSliderTooltipPositionOffset?` | `null` | Offset from default position | ### Example ```dart FlutterSliderTooltip( textStyle: TextStyle(fontSize: 17, color: Colors.white), boxStyle: FlutterSliderTooltipBox( decoration: BoxDecoration( color: Colors.blue.withOpacity(0.8), borderRadius: BorderRadius.circular(4), ), ), format: (value) => ' $value.toStringAsFixed(0)}', alwaysShowTooltip: true, ) ``` ``` -------------------------------- ### Basic Widget Test for Slider Drag Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/quick-start.md A basic widget test demonstrating how to verify that the slider's value updates correctly when dragged. It uses `StatefulBuilder` to manage the state within the test. ```dart testWidgets('Slider updates value on drag', (WidgetTester tester) async { double selectedValue = 300; await tester.pumpWidget( MaterialApp( home: StatefulBuilder( builder: (context, setState) { return Scaffold( body: FlutterSlider( values: [selectedValue], max: 500, min: 0, onDragging: (handlerIndex, lowerValue, upperValue) { setState(() { selectedValue = lowerValue; }); }, ), ); }, ), ), ); // Initial value expect(find.text('300'), findsWidgets); // Drag slider await tester.drag(find.byType(FlutterSlider), Offset(100, 0)); await tester.pumpAndSettle(); // Value should have changed expect(selectedValue, isNot(300)); }); ``` -------------------------------- ### Basic Tooltip Display Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Shows a basic tooltip attached to a slider. This is the default behavior when a tooltip is enabled. ```dart FlutterSlider( values: [300], max: 500, min: 0, tooltip: FlutterSliderTooltip(), ) ``` -------------------------------- ### Configure Fixed Step Size Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Use FlutterSliderStep with a defined step value for uniform increments. ```dart FlutterSlider( values: [100], max: 500, min: 0, step: FlutterSliderStep(step: 10), ) ``` -------------------------------- ### Smooth Bounce Handler Animation Source: https://github.com/loonix/another_xlider/blob/master/_autodocs/advanced-features.md Implement a smooth bounce animation for handlers using specific curves and duration. ```dart FlutterSliderHandlerAnimation( curve: Curves.bounceOut, reverseCurve: Curves.easeIn, duration: Duration(milliseconds: 400), scale: 1.2, ) ```