from typing import override

from flut._flut.engine import FlutImmutableObject
from flut._flut.runtime import _flut_unpack_required_field
from flut.dart.ui import Offset


class _Velocity(FlutImmutableObject):

    def __init__(
        self,
        *,
        pixelsPerSecond: Offset,
    ):
        super().__init__("Velocity")
        self.pixelsPerSecond = pixelsPerSecond

    @override
    def _flut_pack(self) -> dict:
        result = self._flut_base_props()
        result["pixelsPerSecond"] = self.pixelsPerSecond._flut_pack()
        return result

    @staticmethod
    def _flut_unpack(data: dict) -> "Velocity":
        return Velocity(
            pixelsPerSecond=_flut_unpack_required_field(data, "pixelsPerSecond"),
        )


class Velocity(_Velocity):
    zero = _Velocity(pixelsPerSecond=Offset(0, 0))
