from typing import Optional, override

from flut.flutter.widgets.framework import Widget


class FloatingActionButton(Widget):
    def __init__(
        self,
        *,
        key=None,
        tooltip: Optional[str] = None,
        onPressed=None,
        child: Optional[Widget] = None,
    ):
        super().__init__("FloatingActionButton", key=key)
        self.tooltip = tooltip
        self.onPressed = onPressed
        self.child = child

    @override
    def _flut_pack(self) -> dict:
        result = self._flut_base_props()
        if self.tooltip is not None:
            result["tooltip"] = self.tooltip
        result["onPressedId"] = self._register_action(self.onPressed) if self.onPressed is not None else None
        if self.child is not None:
            result["child"] = self.child._flut_pack()
        return result

