from pathlib import Path


def read_version_from_sdk(path: str) -> str:
    """Reads the version from the Flutter SDK.
    
    Given the path to the SDK, the ``engine.version`` file located
    at ``{path}/bin/internal/engine.version`` will be used to read
    the version.

    .. warning::

        This function should not be called from user code.
        Use the safer and more universal implementation
        :func:`get_flutter_version` instead.

    Parameters
    ----------
    path : str
        Path to the Flutter SDK.
    
    Returns
    -------
    str
        The version string.
    """

    sdk_path = Path(path).joinpath('bin', 'internal')

    with open(str(sdk_path / 'engine.version'), encoding='utf-8') as f:
        return f.read().strip()