value<T> method
dynamic
value<
T>( - T? defaultValue, {
- bool visitorExposed = true,
})
Implementation
dynamic value<T>(T? defaultValue, {bool visitorExposed = true}) {
dynamic retValue = defaultValue;
this._defaultValue = defaultValue;
Modification? modif = this._visitorDelegate?.getFlagModification(this._key);
if (modif != null) {
try {
{
if (modif.value == null) {
// Activate if necessary
if (visitorExposed) {
this.visitorExposed();
}
} else if (_isSameTypeOrDefaultValueNull(modif.value)) {
/// Get the flag value
// Activate if necessary
if (visitorExposed) {
this.visitorExposed();
}
return modif.value;
} else {
Flagship.logger(Level.DEBUG,
"For the visitor ${this._visitorDelegate?.visitor.visitorId} , the flag with key ${this.key} has a different type compared to the default value. Therefore, the default value ${defaultValue} has been returned.");
// Fix later this line
DataUsageTracking.sharedInstance().proceesTroubleShootingFlag(
CriticalPoints.GET_FLAG_VALUE_TYPE_WARNING.name,
this,
this._visitorDelegate?.visitor ??
VisitorBuilder("", false).build());
}
}
} catch (exp) {
Flagship.logger(Level.INFO,
"an exception raised $exp , will return a default value ");
}
} else {
DataUsageTracking.sharedInstance().proceesTroubleShootingFlag(
CriticalPoints.GET_FLAG_VALUE_FLAG_NOT_FOUND.name,
this,
this._visitorDelegate?.visitor ?? VisitorBuilder("", false).build());
//
Flagship.logger(Level.DEBUG,
"For the visitor ${this._visitorDelegate?.visitor.visitorId} , no flags were found with the key ${this.key}.Therefore, the default value ${defaultValue} has been returned ");
}
return retValue;
}