I know that in Flutter composition is preferred over inheritance but for one use case I need my class to extend Text, since parameter only accepts Text classes & not all Widgets
Thing is I need to deal with States in this new class there for I was wondering if I can have
this class NeedsToBeStateful extends Text {} be something of Text extends StatefulWidget rather than class Text extends StatelessWidget
I would also need the Text data to be updated by the State
class NeedsToBeStateful extends Text {
NeedsToBeStateful(
{super.data = dataUpdatedByState}
);
@override
Text build(BuildContext context) {
return Text(
data,
);
}
}
I was thinking of doing something like this but it didn't work
class NeedsToBeStateful extends Text with StatefulWidget{
NeedsToBeStateful(
{super.data = dataUpdatedByState}
);
@override
Text build(BuildContext context) {
return Text(
data,
);
}
}