buildByCupertinoWithChild method
Final build method, for compatibility with BaseButton.icon
Implementation
Widget buildByCupertinoWithChild(Widget child) {
assert(child != null, 'child can\'t be null.');
// Check if CNButton should be used
final bool _useCNButton = valueOf('useCNButton', useCNButton);
if (_useCNButton) {
return _buildCNButton(child);
}
// Original CupertinoButton implementation
final Color _disabledColor = valueOf('disabledColor', disabledColor) ?? CupertinoColors.quaternarySystemFill;
final EdgeInsetsGeometry? _padding = valueOf('padding', padding);
final VoidCallback? _onPressed = valueOf('onPressed', onPressed);
final double _minSize = valueOf('minSize', minSize);
final double _pressedOpacity = valueOf('minSize', pressedOpacity);
final BorderRadius? _borderRadius = valueOf('borderRadius', borderRadius);
final AlignmentGeometry _alignment = valueOf('alignment', alignment);
final bool _adaptiveHaptics = valueOf('adaptiveHaptics', adaptiveHaptics);
// Enhanced onPressed with haptic feedback
VoidCallback? _enhancedOnPressed;
if (_onPressed != null) {
_enhancedOnPressed = () {
if (_adaptiveHaptics) {
HapticFeedback.lightImpact();
}
_onPressed();
};
}
Widget button;
if (filledButton) {
button = CupertinoButton.filled(
child: child,
padding: _padding,
disabledColor: _disabledColor,
minSize: _minSize,
pressedOpacity: _pressedOpacity,
borderRadius: _borderRadius,
alignment: _alignment,
onPressed: _enhancedOnPressed,
);
} else {
button = CupertinoButton(
child: child,
padding: _padding,
color: valueOf('color', color),
disabledColor: _disabledColor,
minSize: _minSize,
pressedOpacity: _pressedOpacity,
borderRadius: _borderRadius,
alignment: _alignment,
onPressed: _enhancedOnPressed,
);
}
return button;
}