Is it possible to extend private Dart classes?
You can only extend a class that you can refer to. If _DismissibleState
is declared in a different library, then you cannot refer to it, and so you can't extend it.
There is no workaround. That's what it means to be private.
You also cannot extend Dismissible
to return a different state because its interface contains _DismissibleState createState()
. There is no way you can return a state which satisfies that interface restriction, and you also cannot override it with a different return type unless that type also implements _DismissibleState
, which was the original unsolvable problem.
vstollen
I currently study Computer Science at the TU Darmstadt.
Updated on December 14, 2022Comments
-
vstollen over 1 year
I am trying to expand upon the functionality of the
Dismissible
widget, which is aStatefulWidget
, with its state being a private class.Since I need to change the functionality inside of
_DismissibleState
, is it possible to somehow extend from it?If not, is there an alternative or recommended way how to extend upon Flutter standard classes, apart from copying the whole source?