How can I inherit a StatefulWidget's State?

160 Views Asked by At

Say I have a GenericListItem which is a StatefulWidget and calls

@override
GenericListItemState createState() => new GenericListItemState();

and say that GenericListItemState (created as class GenericListItemState extends State<GenericListItem>) contains the build method and all the real logic for manipulating GenericListItems.

If I want to create a SpecificListItem class which is just like a GenericListItem except it handles a couple methods differently, how do I go about this? I can create a SpecificListItem which extends GenericListItem and overrides its createState() method but how do I extend the GenericListItemState that has all the important logic, including the methods I need to override? Aren't I required to create my SpecificListItemState so it extends State<SpecificListItem>?

1

There are 1 best solutions below

1
On BEST ANSWER

Apparently it does work if I just do SpecificListItemState extends GenericListItemState. Problem solved.