showMagnifier method

void showMagnifier(
  1. MagnifierInfo initialMagnifierInfo
)

Shows the magnifier, and hides the toolbar if it was showing when showMagnifier was called. This is safe to call on platforms not mobile, since a magnifierBuilder will not be provided, or the magnifierBuilder will return null on platforms not mobile.

This is NOT the source of truth for if the magnifier is up or not, since magnifiers may hide themselves. If this info is needed, check MagnifierController.shown.

Implementation

void showMagnifier(MagnifierInfo initialMagnifierInfo) {
  if (toolbarIsVisible) {
    hideToolbar();
  }

  // Start from empty, so we don't utilize any remnant values.
  _magnifierInfo.value = initialMagnifierInfo;

  // Pre-build the magnifiers so we can tell if we've built something
  // or not. If we don't build a magnifiers, then we should not
  // insert anything in the overlay.
  final Widget? builtMagnifier = magnifierConfiguration.magnifierBuilder(
    context,
    _magnifierController,
    _magnifierInfo,
  );

  if (builtMagnifier == null) {
    return;
  }

  _magnifierController.show(
      context: context,
      below: magnifierConfiguration.shouldDisplayHandlesInMagnifier
          ? null
          : _handles?.start,
      builder: (_) => builtMagnifier);
}