FeaturesConfig.fromJson constructor
Creates a FeaturesConfig instance from a JSON map.
This factory constructor parses a JSON map and creates a corresponding
FeaturesConfig object. It expects the JSON map to optionally contain
the keys 'featureOneEnabled', 'featureTwoEnabled', 'enableBetaFeatures',
and 'featureFlag'. Missing keys will result in null values for the
corresponding fields.
Example JSON:
{
"featureOneEnabled": true,
"featureTwoEnabled": false,
"enableBetaFeatures": true,
"featureFlag": null // Example of a missing value
}
Note that although the fields are nullable, providing incorrect types in the JSON (e.g., a String where a bool is expected) will still result in a TypeError.
Implementation
factory FeaturesConfig.fromJson(Map<String, dynamic> json) {
return FeaturesConfig(
featureOneEnabled: json['featureOneEnabled'] as bool?,
featureTwoEnabled: json['featureTwoEnabled'] as bool?,
enableBetaFeatures: json['enableBetaFeatures'] as bool?,
featureFlag: json['featureFlag'] as bool?,
);
}