toggleFullscreen static method

bool toggleFullscreen(
  1. bool enable
)

Toggles browser's fullscreen to enable, and returns the resulting fullscreen state.

Always returns false if fullscreen is not supported.

Implementation

static bool toggleFullscreen(bool enable) {
  try {
    if (enable) {
      if (requestFullscreenClosure != null) {
        requestFullscreen();
      } else if (mozRequestFullScreenClosure != null) {
        mozRequestFullScreen();
      } else if (webkitRequestFullScreenClosure != null) {
        webkitRequestFullScreen();
      } else if (msRequestFullscreenClosure != null) {
        msRequestFullscreen();
      }
    } else {
      if (exitFullscreenClosure != null) {
        exitFullscreen();
      } else if (mozCancelFullScreenClosure != null) {
        mozCancelFullScreen();
      } else if (webkitCancelFullScreenClosure != null) {
        webkitCancelFullScreen();
      } else if (msExitFullscreenClosure != null) {
        msExitFullscreen();
      }
    }
  } catch (e) {
    Log.debug('Can\'t toggle fullscreen: $e', 'WebUtils');
    return false;
  }

  return enable;
}