fix: update ExperienceAdapter to ensure consistent return type and improve null handling

This commit is contained in:
Achintha Isuru
2026-01-27 15:17:58 -05:00
parent c91155ee61
commit 1870be4cb8

View File

@@ -1,23 +1,18 @@
import 'package:flutter/foundation.dart';
/// Adapter for Experience data (skills/industries) to map data layer values to domain models.
class ExperienceAdapter {
/// Converts a dynamic list (from backend AnyValue) to List<String>.
///
/// Handles nulls and converts elements to Strings.
static List<String> fromDynamicList(dynamic data) {
if (data == null) return [];
if (data == null) return <String>[];
if (data is List) {
return data
.where((e) => e != null)
.map((e) => e.toString())
.where((dynamic e) => e != null)
.map((dynamic e) => e.toString())
.toList();
}
// In case it comes as a map or single value, we treat it as empty or single?
// Safer to just return empty if not a list for now.
debugPrint('ExperienceAdapter: Expected List but got ${data.runtimeType}');
return [];
return <String>[];
}
}