Skip to content
Get started
Menu
Get started

Chart module

Show monthly spending with a host-computed headline, a chart and explicit loading, empty and retry states. Put it directly in OverviewPage.

Spending charts with host-provided headlines and explicit chart states. Part 1 of 2.Continued: Spending charts with host-provided headlines and explicit chart states. Part 2 of 2.Spending charts with host-provided headlines and explicit chart states. Part 1 of 2.Continued: Spending charts with host-provided headlines and explicit chart states. Part 2 of 2.
Light and dark variants Shown in 2 images, top to bottom; each repeats the last few lines of the one before.
Spending charts with host-provided headlines and explicit chart states at 200 percent text. Part 1 of 2.Continued: Spending charts with host-provided headlines and explicit chart states at 200 percent text. Part 2 of 2.
200% text Shown in 2 images, top to bottom; each repeats the last few lines of the one before.
example/lib/screens/gallery_charts.dart
ChartModule(
title: 'Spending, this month vs last month',
state: ChartState.ready,
showHeadline: false,
height: kind == 'meter' ? null : 180,
chart: chart,
);

Variants: ready, loading, empty, error.

Situation Variant / composition Payment example
Monthly spending ready The host supplies headline and chart state; retry repeats only the chart request.

Use Overview page to arrange several modules.

Choose the state from what the host knows:

The host knows… State
The request is pending loading
The request failed error, with retry
There are no readings empty, with an explanation
Readings are available ready, with the chart

The headline block reserves a caption line only when you pass headlineCaption or delta, so a bare amount sits right above the chart’s value band. Above 1.5× text the plot height is capped at compactHeight; heights stay identical across loading, error, empty and ready. The one exception is a ready multi-series line or bar chart whose value label stacks each series name over its value: the plot area grows by those extra lines so the plot itself keeps its height. Loading keeps the module heading and chart shape. Empty explains the absence of readings; error offers host retry. Ready requires a chart and uses only the supplied headline.

Chart module loading state with its heading and loading placeholder.
Loading
Chart module error message with a Retry action.
Error and retry
Chart module empty state explaining that there are no readings.
Empty

Do: The host supplies headline and chart state; retry repeats only the chart request.

Don’t: Compute ledger totals inside the chart widget.

Name what the headline measures and the period it covers. Explain an empty or failed plot in its message, with a retry action when available.

Supply a headline and chart summary that identify the data without relying on color. Keep error messages and retry reachable at large text.

Example history screen with synthetic dataExample history screen with synthetic data
Example: history

ChartModule

class ChartModule extends StatelessWidget · lib/src/charts/charts.dart

A chart section with stable loading, empty and error states.

ParameterTypeDefaultDescription
title:requiredString—Title.
state:requiredChartState—State.
chart:Widget?—Chart.
headline:Money?—Host-provided amount. The kit never computes a headline total.
headlineCaption:String?—Headline Caption.
showHeadline:booltrueShow Headline.
delta:String?—Delta.
deltaTone:StatusToneStatusTone.neutralDelta Tone.
height:double?compactHeightHeight.
emptyTitle:String?—Empty Title.
emptyMessage:String?—Empty Message.
errorMessage:String?—Error Message.
onRetry:FutureOr<void> Function()?—On Retry.
trailing:Widget?—Trailing.

ChartState

enum ChartState · lib/src/charts/chart_models.dart

Host-owned chart loading state.

ValueDescription
loadingFetch in progress.
readyData available.
emptyNo data available.
errorFetch failed.