decodeMigrationWarnings function
Decodes warnings from either JSON or the legacy line-based format.
Implementation
List<String> decodeMigrationWarnings(String? rawWarnings) {
if (rawWarnings == null || rawWarnings.trim().isEmpty) {
return const <String>[];
}
final trimmed = rawWarnings.trim();
try {
final decoded = jsonDecode(trimmed);
if (decoded is List) {
return decoded.map((value) => '$value').toList(growable: false);
}
} on FormatException {
// Fall back to the legacy line-based representation.
}
return trimmed
.split('\n')
.map((line) => line.trim())
.where((line) => line.isNotEmpty)
.toList(growable: false);
}