ChartVisibilityController class

Controller that tracks which series are currently hidden.

Pass an instance to ChartLegendScope (or use it standalone with a ChartLegend you build yourself) to keep visibility state outside the widget tree, for example to persist it across rebuilds or share it across multiple charts.

Example

final controller = ChartVisibilityController();
// ...
controller.hide(Colors.red);
controller.toggle(Colors.blue);
if (controller.isHidden(Colors.red)) { /* ... */ }
Inheritance

Constructors

ChartVisibilityController({Iterable<Color> initiallyHidden = const <Color>[]})

Properties

hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
hidden Set<Color>
Unmodifiable view of the hidden colors.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
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
filter(List<ChartDataSet> dataSets) List<ChartDataSet>
Filters a list of ChartDataSets, removing any whose color is hidden.
hide(Color color) → void
isHidden(Color color) bool
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
show(Color color) → void
showAll() → void
solo(Color color, Iterable<Color> all) → void
Hide everything except color. Useful for "solo" legend interactions (double-tap or long-press).
toggle(Color color) → void
toString() String
A string representation of this object.
inherited

Operators

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