CliqitDataModel.fromMap constructor
CliqitDataModel.fromMap(
- Map map
Implementation
factory CliqitDataModel.fromMap(Map<dynamic, dynamic> map) {
// Helper to handle status which might come as Bool or String
bool? parseStatus(dynamic value) {
if (value is bool) return value;
if (value is String) {
return value.toLowerCase() == 'true' ||
value.toLowerCase() == 'opened' ||
value.toLowerCase() == 'matched';
}
return null;
}
return CliqitDataModel(
url: map['url'] as String?,
path: map['path'] as String?,
isDeferred: map['isDeferred'] as bool? ?? false,
source: map['source'] as String?,
parameters: (map['parameters'] as Map?)?.cast<String, dynamic>() ?? {},
clickSessionId: map['clickSessionId'] as String?,
status: parseStatus(map['status']),
destinationPath: (map['destinationPath'] as String?) ?? (map['destination'] as String?),
slug: map['slug'] as String?,
appName: map['appName'] as String?,
appId: map['appId'] as String?,
mismatchMessage: map['mismatchMessage'] as String?,
error: (map['error'] as String?) ?? (map['errorMessage'] as String?),
message: map['message'] as String?,
isDeepLink: map['isDeepLink'] as bool?,
matched: map['matched'] as bool?,
tier: map['tier'] as String?,
confidence: map['confidence'] as String?,
score: (map['score'] as num?)?.toDouble(),
);
}