refactor: Switch to singleton pattern in app_env.dart
Hey 👋
Little change that, I thought, is quite nice, especially regarding people who copy the example & use it straightaway.
The reasoning is that it is plain better, & more efficent to implement the Singleton pattern with the Dart Factories for the AppEnv than to create a new instance with each call to the constructor
Is done! Sorry, something went wrong on my side there.
How's this going ?
Does this really make any difference? As far as I can see, there is always only a single instance that is being created since the field was always marked static final.
The "constructor" (i.e., factory) just returns this instance that was created at some point - basically the same procedure as a singleton, just easier to read, less to write and exactly as efficient.
Because of this, I actually prefer the old code.
As far as I can see, there is always only a single instance that is being created since the field was always marked
static final.
Fair point.