from typing import override

from flut._flut.engine import FlutAbstractObject
from flut.dart.ui import Canvas, Size


class CustomPainter(FlutAbstractObject):
    def __init__(self):
        super().__init__("CustomPainter")

    def paint(self, canvas: Canvas, size: Size):
        pass

    def shouldRepaint(self, oldDelegate: "CustomPainter") -> bool:
        return True

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