rowLayout function
VenueLayoutDocument
rowLayout(
{ - int rows = 5,
- int seatsPerRow = 8,
- int blocks = 1,
- double aisle = 80,
- double spacing = 56,
- double rowSpacing = 64,
- double x = 100,
- double y = 100,
- double arc = 0,
- String? id,
- TableSeating seating = const TableSeating(),
})
Implementation
VenueLayoutDocument rowLayout({
int rows = 5,
int seatsPerRow = 8,
int blocks = 1,
double aisle = 80,
double spacing = 56,
double rowSpacing = 64,
double x = 100,
double y = 100,
double arc = 0,
String? id,
TableSeating seating = const TableSeating(),
}) {
if (rows < 1 ||
seatsPerRow < 1 ||
blocks < 1 ||
rows * seatsPerRow * blocks > 20000) {
throw ArgumentError('Invalid row count');
}
if (!spacing.isFinite ||
spacing <= 0 ||
!rowSpacing.isFinite ||
rowSpacing <= 0 ||
!aisle.isFinite ||
aisle < 0 ||
!arc.isFinite ||
!x.isFinite ||
!y.isFinite) {
throw ArgumentError('Invalid row geometry');
}
final root = id ?? newLayoutId(),
parameters = <String, dynamic>{
'rows': rows,
'seatsPerRow': seatsPerRow,
'blocks': blocks,
'aisle': aisle,
'spacing': spacing,
'rowSpacing': rowSpacing,
'arc': arc,
};
final nodes = <LayoutNode>[
LayoutNode(
id: root,
kind: 'group',
x: x,
y: y,
properties: const {},
assembly: {'kind': 'rows', ...parameters},
seating: seating.record,
),
for (var r = 0; r < rows; r++)
for (var b = 0; b < blocks; b++)
for (var i = 0; i < seatsPerRow; i++)
LayoutNode(
id: newLayoutId(),
kind: 'seat',
width: seating.width,
height: seating.height,
parentId: root,
x: b * (seatsPerRow * spacing + aisle) + i * spacing,
y: r * rowSpacing + arc * pow(i - (seatsPerRow - 1) / 2, 2),
rotation:
atan(2 * arc * (i - (seatsPerRow - 1) / 2) / spacing) *
180 /
pi,
label: _rowSeatLabel(r, b * seatsPerRow + i),
properties: {'slot': '$r:$b:$i'},
),
];
return VenueLayoutDocument(
schemaVersion: 2,
nodes: nodes,
seatingDefaults: seating.record,
attachments: [
for (final node in nodes.where((node) => node.kind == 'seat'))
{
'seatId': node.id,
'targetId': root,
'rotationMode': 'auto',
'placement': {'mode': 'automatic'},
},
],
);
}