build method
- BuildContext context
override
It builds a cross of 6x6 buttons, with the buttons' colors and text being determined by the result value notifier
Args: context (BuildContext): The context of the widget.
Returns: A widget that displays the cross.
Implementation
@override
Widget build(BuildContext context) {
containerDimension = MediaQuery.of(context).size.width / 28;
sizeBoxDimension = MediaQuery.of(context).size.width / 200;
final double widgetDimension = (containerDimension + sizeBoxDimension) * 6;
buttons = List<List<Widget>>.generate(
6,
(int i) => List<Widget>.filled(6, _buildDummy()),
);
if (widget.resultValueNotifier != null) {
for (int y = 0; y < buttons.length; y++) {
if (<int>[0, 1, 4, 5].contains(y)) {
buttons[y][2] = _buttonBuilderFromColor(
widget.resultValueNotifier!.cross.getGrid[y][2],
);
buttons[y][3] = _buttonBuilderFromColor(
widget.resultValueNotifier!.cross.getGrid[y][3],
);
} else {
for (int x = 0; x < buttons[y].length; x++) {
buttons[y][x] = _buttonBuilderFromColor(
widget.resultValueNotifier!.cross.getGrid[y][x],
);
}
}
}
} else if (widget.reference) {
for (int y = 0; y < buttons.length; y++) {
if (<int>[0, 1, 4, 5].contains(y)) {
buttons[y][2] = _buttonBuilderReference(y, 2);
buttons[y][3] = _buttonBuilderReference(y, 3);
} else {
for (int x = 0; x < buttons[y].length; x++) {
buttons[y][x] = _buttonBuilderReference(y, x);
}
}
}
} else {
for (int y = 0; y < buttons.length; y++) {
if (<int>[0, 1, 4, 5].contains(y)) {
buttons[y][2] = _buttonBuilder(y, 2);
buttons[y][3] = _buttonBuilder(y, 3);
} else {
for (int x = 0; x < buttons[y].length; x++) {
buttons[y][x] = _buttonBuilder(y, x);
}
}
}
}
return SizedBox(
width: widgetDimension,
height: widgetDimension,
child: Flex(direction: Axis.vertical, children: _buildCross()),
);
}