from flut._flut.engine import FlutRealtimeObject


class TextEditingController(FlutRealtimeObject):

    def __init__(self, text=None):
        props = {}
        if text is not None:
            props["text"] = text
        super().__init__(
            "TextEditingController",
            props=props,
            bindings=[
                ("buildTextSpanId", self.buildTextSpan, TextEditingController, "buildTextSpan"),
            ],
        )

    @property
    def text(self):
        return self._get("text")

    @text.setter
    def text(self, value):
        self._set("text", value)

    def clear(self):
        self.text = ""

    def buildTextSpan(self, text):
        raise NotImplementedError()
