I have this question for a job interview, and i want to know why the stateful and staless widgets, use extends and why not use implements in Flutter/Dart?
Asked
Active
Viewed 182 times
0
-
You can checkout the answer here showing difference between `extends`, `implements` and `with`: https://stackoverflow.com/q/55295782/10488444 – Bach Mar 01 '21 at 08:14
1 Answers
0
extends
is usually the go-to when you want to make a more specific version of a class.
When you extend a class, you inherit all properties, methods, etc.
If you want to override a method, you prefix the method with @override
.
implements
is when you want to make a whole new version of a class but you want to inherit the class type.
When you create a new implementation of a class, you are responsible for supplying everything necessary to make that class function.

ReyHaynes
- 2,932
- 1
- 15
- 22