I'm trying to do an env setup to flutter the project with null safety. but this error popped.
this worked well with the project without null safety.
class Environment {
factory Environment() {
return _singleton;
}
Environment._internal();
// here
// Non-nullable instance field 'config' must be initialized.
// Try adding an initializer expression, or add a field initializer in this constructor,or mark it 'late'
static final Environment _singleton = Environment._internal();
static const String DEV = 'DEV';
static const String STAGING = 'STAGING';
static const String PROD = 'PROD';
BaseConfig config;
initConfig(String environment) {
config = _getConfig(environment);
}
BaseConfig _getConfig(String environment) {
switch (environment) {
case Environment.PROD:
return ProdConfig();
case Environment.STAGING:
return StagingConfig();
default:
return DevConfig();
}
}
}