switchField method
Implementation
String switchField(String elementName, String type, Map<String, dynamic> map, {String? parent}) {
final initialValue = map['initialValue'] ?? 0.0;
final autovalidateMode = map['autovalidateMode'] ?? 'AutovalidateMode.onUserInteraction';
return '''
SizedBox(
height: 60,
child: SwitchFormField(
initialValue: $initialValue,
autovalidateMode: $autovalidateMode,
onSaved: (value) => onSaved('${elementName}', value, parent: '${parent ?? ''}'),
${buildValidator(map['validators'] as List<Map<String, dynamic>>?)},
onChanged: (value) => onSaved('${elementName}', value, parent: '${parent ?? ''}'),
label: '${map['label'] ?? elementName}',
hint: '${map['hint'] ?? ''}',
suffix: '${map['suffix'] ?? ''}',
prefix: '${map['prefix'] ?? ''}',
icon: '${map['icon'] ?? ''}',
iconSize: ${map['iconSize'] ?? 24},
iconColor: ${map['iconColor'] ?? 'Colors.grey[600]'},
iconTooltip: '${map['iconTooltip'] ?? ''}',
iconOnTap: () => ${map['iconOnTap'] ?? null},
iconOnLongPress: () => ${map['iconOnLongPress'] ?? null},
iconOnDoubleTap: () => ${map['iconOnDoubleTap'] ?? null},
color: ${map['color'] ?? 'Colors.grey[300]'},
colorActive: ${map['colorActive'] ?? 'Colors.grey[500]'},
colorHover: ${map['colorHover'] ?? 'Colors.grey[400]'},
colorDisabled: ${map['colorDisabled'] ?? 'Colors.grey[100]'},
colorFocus: ${map['colorFocus'] ?? 'Colors.grey[200]'},
colorError: ${map['colorError'] ?? 'Colors.red[300]'},
enabled: ${map['enabled'] ?? true},
hide: ${map['hide'] ?? false},
readOnly: ${map['readOnly'] ?? false},
autofocus: ${map['autofocus'] ?? false},
)
''';
}