Home > front end >  Why do some classes provide a way to create compile-time objects using constant constructors, why so
Why do some classes provide a way to create compile-time objects using constant constructors, why so

Time:10-17

Why do some classes provide a way to create compile-time objects using constant constructors, why some don't? Are there any reasons behind that? I couldn't find anywhere that tells me that.

Like AppBar class, for example, doesn't allow us to create a compile-time object. While MaterialApp class provides us to create a compile-time object.

CodePudding user response:

Only a qualifying class can have a const constructor. For example, all of the properties must be final. And, the author of the class must provide a const constructor explicitly. Some authors forget to do that.

  • Related