hlmapAspectRatioPreset function
Maps a string name to the corresponding hl_image_picker.CropAspectRatioPreset
.
This function returns the appropriate aspect ratio preset for cropping images
based on the provided name
. If the name is not recognized, it defaults to
hl_image_picker.CropAspectRatioPreset.square
.
name
- The aspect ratio preset as a string (e.g., 'original', 'square', 'ratio3x2').
Returns: The corresponding hl_image_picker.CropAspectRatioPreset
value.
Implementation
hl_image_picker.CropAspectRatioPreset hlmapAspectRatioPreset(String name) {
switch (name) {
case 'original':
return hl_image_picker.CropAspectRatioPreset.original;
case 'square':
return hl_image_picker.CropAspectRatioPreset.square;
case 'ratio3x2':
return hl_image_picker.CropAspectRatioPreset.ratio3x2;
case 'ratio4x3':
return hl_image_picker.CropAspectRatioPreset.ratio4x3;
case 'ratio5x3':
return hl_image_picker.CropAspectRatioPreset.ratio5x3;
case 'ratio5x4':
return hl_image_picker.CropAspectRatioPreset.ratio5x4;
case 'ratio16x9':
return hl_image_picker.CropAspectRatioPreset.ratio16x9;
default:
// Default to square aspect ratio if the input is invalid.
return hl_image_picker.CropAspectRatioPreset.square;
}
}