from typing import Optional, override

from flut.flutter.widgets.framework import Widget


class ElevatedButton(Widget):

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

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