RangeController class

Coordinates between SfRangeSelector and the widget which listens to it.

Built-in support for selection and zooming with SfChart.

Range controller contains start and end values.

start - represents the currently selected start value of a range selector. The start thumb of the range selector was drawn corresponding to this value.

end - represents the currently selected end value of the range selector. The end thumb of the range selector was drawn corresponding to this value.

start and end can be either double or DateTime.

Selection in SfChart.

class RangeSelectorPage extends StatefulWidget {
  const RangeSelectorPage({ Key key }) : super(key: key);
  @override
  _RangeSelectorPageState createState() => _RangeSelectorPageState();
}

class _RangeSelectorPageState extends State<RangeSelectorPage>
    with SingleTickerProviderStateMixin {
 final double _min = 2.0;
 final double _max = 10.0;
 RangeController _rangeController;

@override
void initState() {
  super.initState();
    _rangeController = RangeController(
    vsync: this,
    start: _values.start,
    end: _values.end);
}

@override
void dispose() {
  _rangeController.dispose();
  super.dispose();
}

final List<Data> chartData = <Data>[
   Data(x:2.0, y: 2.2),
   Data(x:3.0, y: 3.4),
   Data(x:4.0, y: 2.8),
   Data(x:5.0, y: 1.6),
   Data(x:6.0, y: 2.3),
   Data(x:7.0, y: 2.5),
   Data(x:8.0, y: 2.9),
   Data(x:9.0, y: 3.8),
   Data(x:10.0, y: 3.7),
];

@override
Widget build(BuildContext context) {
 return MaterialApp(
     home: Scaffold(
         body: Center(
             child: SfRangeSelector(
                   min: _min,
                   max: _max,
                   interval: 1,
                   showTicks: true,
                   showLabels: true,
                  controller: _rangeController,
                   child: Container(
                   height: 130,
                  child: SfCartesianChart(
                       margin: const EdgeInsets.all(0),
                       primaryXAxis: NumericAxis(minimum: _min,
                           maximum: _max,
                           isVisible: false),
                       primaryYAxis: NumericAxis(isVisible: false),
                       plotAreaBorderWidth: 0,
                       series: <SplineAreaSeries<Data, double>>[
                           SplineAreaSeries<Data, double>(
                               selectionSettings: SelectionSettings(
                                   enable: true,
                                   selectionController: _rangeController),
                              color: Color.fromARGB(255, 126, 184, 253),
                               dataSource: chartData,
                                   xValueMapper: (Data sales, _) => sales.x,
                                   yValueMapper: (Data sales, _) => sales.y)
                            ],
                        ),
                    ),
                ),
            )
        )
    );
  }
}

Zooming in SfChart.

class RangeZoomingPage extends StatefulWidget {
  const RangeZoomingPage({ Key key }) : super(key: key);
  @override
  _RangeZoomingPageState createState() => _RangeZoomingPageState();
}

class _RangeZoomingPageState extends State<RangeZoomingPage>
    with SingleTickerProviderStateMixin {
 final double _min = 2.0;
 final double _max = 10.0;
 RangeController _rangeController;

@override
void initState() {
  super.initState();
    _rangeController = RangeController(
    vsync: this,
    start: _values.start,
    end: _values.end);
}

@override
void dispose() {
  _rangeController.dispose();
  super.dispose();
}

final List<Data> chartData = <Data>[
   Data(x:2.0, y: 2.2),
   Data(x:3.0, y: 3.4),
   Data(x:4.0, y: 2.8),
   Data(x:5.0, y: 1.6),
   Data(x:6.0, y: 2.3),
   Data(x:7.0, y: 2.5),
   Data(x:8.0, y: 2.9),
   Data(x:9.0, y: 3.8),
   Data(x:10.0, y: 3.7),
];

@override
Widget build(BuildContext context) {
 return MaterialApp(
     home: Scaffold(
         body: Center(
             child: SfRangeSelector(
                   min: _min,
                   max: _max,
                   interval: 1,
                   showTicks: true,
                   showLabels: true,
                  controller: _rangeController,
                   child: Container(
                   height: 130,
                  child: SfCartesianChart(
                       margin: const EdgeInsets.all(0),
                       primaryXAxis: NumericAxis(minimum: _min,
                           maximum: _max,
                           isVisible: false,
                           rangeController: _rangeController),
                       primaryYAxis: NumericAxis(isVisible: false),
                       plotAreaBorderWidth: 0,
                       series: <SplineAreaSeries<Data, double>>[
                           SplineAreaSeries<Data, double>(
                              color: Color.fromARGB(255, 126, 184, 253),
                               dataSource: chartData,
                                   xValueMapper: (Data sales, _) => sales.x,
                                   yValueMapper: (Data sales, _) => sales.y)
                            ],
                        ),
                    ),
                ),
            )
        )
    );
  }
}
Inheritance
Mixed-in types

Constructors

RangeController({@required dynamic start, @required dynamic end})
Creates a new instance of RangeController.

Properties

end ↔ dynamic
The current selected end value.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
previousEnd → dynamic
The previously selected end value.
no setter
previousStart → dynamic
The previously selected start value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
start ↔ dynamic
The current selected start value.
getter/setter pair

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
override
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited