from typing import Optional, override

from flut._flut.engine import FlutImmutableObject
from flut.dart.ui import PlaceholderAlignment, TextBaseline
from flut.flutter.widgets.framework import Widget
from flut.flutter.painting.text_style import TextStyle


class WidgetSpan(FlutImmutableObject):
    def __init__(
        self,
        *,
        alignment: PlaceholderAlignment = PlaceholderAlignment.bottom,
        baseline: Optional[TextBaseline] = None,
        style: Optional[TextStyle] = None,
        child: Widget,
    ):
        super().__init__("WidgetSpan")
        self.alignment = alignment
        self.baseline = baseline
        self.style = style
        self.child = child

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