from typing import Optional, override

from flut.flutter.painting import Axis

from .framework import Widget


class SingleChildScrollView(Widget):
    def __init__(
        self,
        *,
        key=None,
        controller=None,
        padding=None,
        scrollDirection: Axis = Axis.vertical,
        child: Optional[Widget] = None,
    ):
        super().__init__("SingleChildScrollView", key=key)
        self.controller = controller
        self.padding = padding
        self.scrollDirection = scrollDirection
        self.child = child

    @override
    def _flut_pack(self) -> dict:
        result = self._flut_base_props()
        result["scrollDirection"] = self.scrollDirection._flut_pack()
        if self.controller is not None:
            result["controller"] = self.controller._flut_pack()
        if self.padding is not None:
            result["padding"] = self.padding._flut_pack()
        if self.child is not None:
            result["child"] = self.child._flut_pack()
        return result
