createCell method

Widget createCell(
  1. AutonomyModel model,
  2. MapCellData cell
)

Creates a widget to display the cell data for the provided cell

Implementation

Widget createCell(AutonomyModel model, MapCellData cell) => Expanded(
  child: DragTarget<AutonomyCell>(
    onAcceptWithDetails: (details) => model.handleDrag(details.data, cell),
    builder: (context, candidates, rejects) => GestureDetector(
      onTap: () => model.toggleMarker(cell),
      child: Container(
        width: 24,
        decoration: BoxDecoration(
          color: getColor(cell.cellType, model),
          border: Border.all(
            color: model.snapToGrid ? Colors.black : Colors.grey.shade500,
          ),
        ),
        child: cell.cellType != AutonomyCell.rover || !model.snapToGrid
            ? null
            : LayoutBuilder(
                builder: (context, constraints) => Container(
                  color: Colors.blue,
                  width: double.infinity,
                  height: double.infinity,
                  margin: EdgeInsets.all(constraints.maxWidth / 15),
                  child: Transform.rotate(
                    angle: -model.roverHeading * pi / 180,
                    child: Icon(
                      Icons.arrow_upward,
                      size: constraints.maxWidth * 24 / 30,
                    ),
                  ),
                ),
              ),
      ),
    ),
  ),
);