build method
- BuildContext context
override
It creates a rounded button.
Args: context: The BuildContext of the widget.
Returns: A CupertinoButton with a child of either an Icon or a Text widget.
Implementation
@override
Widget build(BuildContext context) {
dimension = MediaQuery.of(context).size.width / 13;
return AnimatedBuilder(
animation: context.watch<VisibilityNotifier>(),
builder: (_, __) => AnimatedBuilder(
animation: CatInterpreter(),
builder: (_, __) {
if (!t.isActive) {
buttonColor = context.read<VisibilityNotifier>().visible
? colors[CatInterpreter()
.getLastState
.getGrid[widget.position.first][widget.position.second]]
: colors[0];
}
return Padding(
padding: EdgeInsets.all(dimension / 10),
child: CupertinoButton(
pressedOpacity: 1,
onPressed: () async {
if (widget.selectionMode.value == SelectionModes.transition) {
widget.shakeKey.currentState?.shake();
for (final int i in 9.rangeTo(11)) {
widget.shakeKeyColors[i].currentState?.shake();
}
return;
}
if (widget.selectionMode.value == SelectionModes.select ||
widget.selectionMode.value ==
SelectionModes.selectCopyCells) {
if (CatInterpreter().copyCommandsBuffer.isEmpty) {
_selection();
} else {
_selection2();
}
return;
} else if (widget.selectionMode.value ==
SelectionModes.multiple) {
if (context.read<SelectedColorsNotifier>().isEmpty) {
_selectionMultiple();
} else {
widget.shakeKey.currentState?.shake();
widget.shakeKeyColors.forEach(
(GlobalKey<BlinkWidgetState> element) =>
element.currentState?.shake(),
);
}
return;
}
if (widget.selectionMode.value == SelectionModes.repeat) {
await _normalColoring(
selected:
widget.selectionMode.value == SelectionModes.repeat,
);
return;
}
await _normalColoring();
},
borderRadius: BorderRadius.circular(100),
minSize: dimension,
color: buttonColor,
padding: EdgeInsets.zero,
child: _widget(),
),
);
},
),
);
}