visibleGameSize property

Vector2? visibleGameSize

How much of a game world ought to be visible through the viewport.

When this property is non-null, the viewfinder will automatically select the maximum zoom level such that a rectangle of size visibleGameSize (in game coordinates) is visible through the viewport. If you want a certain dimension to be unconstrained, set it to zero.

For example, if visibleGameSize is set to [100.0, 0.0], the zoom level will be chosen such that 100 game units will be visible across the width of the viewport. Likewise, setting visibleGameSize to [5.0, 10.0] will ensure that 5 or more game units are visible across the width of the viewport, and 10 or more game units across the height.

This property is an alternative way to set the zoom level for the viewfinder. It is persistent too: if the game size changes, the zoom will be recalculated to fit the constraint.

If you set the visibleGameSize you will remove any fixed resolution constraints that you might have previously put.

Implementation

Vector2? get visibleGameSize => _visibleGameSize;
void visibleGameSize=(Vector2? value)

Implementation

set visibleGameSize(Vector2? value) {
  if (value == null || (value.x == 0 && value.y == 0)) {
    _visibleGameSize = null;
  } else {
    assert(
      value.x >= 0 && value.y >= 0,
      'visibleGameSize cannot be negative: $value',
    );
    _visibleGameSize = value;
    _updateZoom();
  }
}