MarketChart class
An interactive trading chart.
- Drag to scroll back in time; pinch, trackpad-pinch or mouse wheel to zoom.
- Long-press (touch) or hover (mouse) to show the crosshair and the values of the candle under it.
- For live prices, rebuild the chart with updated candles. While the latest candle is in view the chart follows new candles; after the user scrolls back, the view stays where it is.
- Use a MarketChartController to jump back to the latest candle or zoom from your own buttons, and onLoadMore to load older history as the user scrolls back.
MarketChart(candles: candles)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MarketChart
Constructors
-
MarketChart({Key? key, required List<
Candle> candles, MarketChartController? controller, MarketChartType type = MarketChartType.candles, bool showVolume = true, List<Indicator> indicators = const [], MarketChartTheme? theme, int? pricePrecision, MarketChartTimeFormatter timeFormatter = defaultTimeFormatter, double initialCandleWidth = 8, double minCandleWidth = 2, double maxCandleWidth = 48, ValueChanged<Candle?> ? onCrosshairChanged, FutureOr<void> onLoadMore()?, int loadMoreThreshold = 20}) -
Creates a chart for
candles, oldest first.const
Properties
-
candles
→ List<
Candle> -
The price data, ordered from oldest to newest.
final
- controller → MarketChartController?
-
Lets you jump to the latest candle and zoom from your own buttons.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
indicators
→ List<
Indicator> -
Indicators to draw: MovingAverage and BollingerBands over the
prices, Rsi and Macd in panels below them (in the order listed).
final
- initialCandleWidth → double
-
Starting width of one candle in pixels, including the gap next to it.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loadMoreThreshold → int
-
How close to the oldest candle (in candles) the view must get before
onLoadMore is called.
final
- maxCandleWidth → double
-
Widest a candle can get when zooming in.
final
- minCandleWidth → double
-
Narrowest a candle can get when zooming out.
final
-
onCrosshairChanged
→ ValueChanged<
Candle?> ? -
Called with the candle under the crosshair when it changes (including
when a live update changes that candle), and with null when the
crosshair goes away.
final
-
onLoadMore
→ FutureOr<
void> Function()? -
Called when the user scrolls near the oldest candle, so you can fetch
older history and add it to the start of candles.
final
- pricePrecision → int?
-
Decimals shown in prices. By default this is worked out from the prices:
as many decimals as they have (see detectPricePrecision).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showVolume → bool
-
Whether to show volume bars under the prices.
final
- theme → MarketChartTheme?
-
Colours and text size. Defaults to MarketChartTheme.dark or
MarketChartTheme.light to match the app's brightness.
final
- timeFormatter → MarketChartTimeFormatter
-
Turns candle times into axis and crosshair labels.
final
- type → MarketChartType
-
Whether to draw candlesticks, a line or an area.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< MarketChart> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
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, int wrapWidth = 65}) → 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 short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited