from typing import override
from flut._flut.engine import FlutImmutableObject


class TextSpan(FlutImmutableObject):
    def __init__(self, text=None, children=None, style=None):
        super().__init__("TextSpan")
        self.text = text
        self.children = children
        self.style = style

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