alignment method
Alignment.x → (x, y) with components in -1..1.
Implementation
(double, double)? alignment(DartValue? v) {
if (v is RefValue &&
(v.path.first == 'Alignment' ||
v.path.first == 'AlignmentDirectional')) {
const named = {
'topLeft': (-1.0, -1.0),
'topStart': (-1.0, -1.0),
'topCenter': (0.0, -1.0),
'topRight': (1.0, -1.0),
'topEnd': (1.0, -1.0),
'centerLeft': (-1.0, 0.0),
'centerStart': (-1.0, 0.0),
'center': (0.0, 0.0),
'centerRight': (1.0, 0.0),
'centerEnd': (1.0, 0.0),
'bottomLeft': (-1.0, 1.0),
'bottomStart': (-1.0, 1.0),
'bottomCenter': (0.0, 1.0),
'bottomRight': (1.0, 1.0),
'bottomEnd': (1.0, 1.0),
};
final hit = named[v.last];
if (hit != null) return hit;
}
final d = deref(v);
if (d is ObjectValue &&
(d.type == 'Alignment' || d.type == 'AlignmentDirectional')) {
return (number(d.arg(0)) ?? 0, number(d.arg(1)) ?? 0);
}
return null;
}