build method
- @override
- BuildContext context,
- ElectricalModel model
override
Builds the UI according to the state in model
.
Implementation
@override
Widget build(BuildContext context, ElectricalModel model) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
PageHeader(
pageIndex: index,
children: [
// The header at the top
const SizedBox(width: 8),
Text("Electrical", style: context.textTheme.headlineMedium),
const SizedBox(width: 12),
const Spacer(),
Text(
model.axis ? "Horizontal" : "Vertical",
style: context.textTheme.labelLarge,
),
const SizedBox(width: 12),
Switch(
value: model.axis,
onChanged: (bool value) => model.changeDirection(),
),
const SizedBox(width: 8),
ElevatedButton.icon(
icon: const Icon(Icons.clear),
label: const Text("Clear all"),
onPressed: model.clear,
),
const SizedBox(width: 8),
],
),
if (model.axis) Expanded(child:
Row(children: [
for (final graph in _getGraphs(model))
Expanded(child: graph),
],),
)
else
for (final graph in _getGraphs(model))
Expanded(child: graph),
const SizedBox(height: 8),
],
);