getAlignment function

Alignment getAlignment(
  1. String? cssAlignment
)

Get flutter Alignment value by cssAlignment

Implementation

Alignment getAlignment(String? cssAlignment) {
  const defaultAlignment = Alignment.center;
  if (cssAlignment == null) {
    return defaultAlignment;
  }

  final index = [
    'topLeft',
    'topCenter',
    'topRight',
    'centerLeft',
    'center',
    'centerRight',
    'bottomLeft',
    'bottomCenter',
    'bottomRight'
  ].indexOf(cssAlignment);
  if (index < 0) {
    return defaultAlignment;
  }

  return [
    Alignment.topLeft,
    Alignment.topCenter,
    Alignment.topRight,
    Alignment.centerLeft,
    Alignment.center,
    Alignment.centerRight,
    Alignment.bottomLeft,
    Alignment.bottomCenter,
    Alignment.bottomRight
  ][index];
}