Search code examples
flutterflutter-widget

Difference between Widget and Stateless widget


In the Flutter docs they say that a Widget is a mutable configuration (description) for an Element, which I have no problem understanding. But then we have the stateless widget, which extends the Widget class, and must implement a build method. The two classes look like they do the same job, can any one explain the difference ?

Thanks.


Solution

  • Widget is just an interface. You're never gonna use it directly, and this class does absolutely nothing.

    It exists just for the compiler to know that your program is type-safe.