dragBehavior property

  1. @override
LinearMarkerDragBehavior dragBehavior
final

Specifies the drag behavior for widget marker pointer.

Defaults to LinearMarkerDragBehavior.free.

This snippet shows how to set drag behavior for widget pointer.

double _startMarkerValue = 30.0;
double _endMarkerValue = 60.0;

@override
Widget build(BuildContext context) {
  return MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: const Text('Drag behavior'),
      ),
      body: SfLinearGauge(
        markerPointers: [
          LinearWidgetPointer(
            value: _startMarkerValue,
            dragBehavior: LinearMarkerDragBehavior.constrained,
            onChanged: (double value) {
              setState(() {
                _startMarkerValue = value;
              });
            },
            child: Container(
              height: 20.0,
              width: 20.0,
              color: Colors.red,
            ),
          ),
          LinearWidgetPointer(
            value: _endMarkerValue,
            onChanged: (double value) {
              setState(() {
                _endMarkerValue = value;
              });
            },
            child: Container(
              height: 20.0,
              width: 20.0,
              color: Colors.red,
            ),
          )
        ],
      ),
    ),
  );
}

Implementation

@override
final LinearMarkerDragBehavior dragBehavior;