getFirstInListFromJson function

  1. @visibleForTesting
String? getFirstInListFromJson(
  1. Map<String, dynamic>? json
)

Helper function to parse first element from json If there is no element, or element is not string it will return you null

Implementation

@visibleForTesting
String? getFirstInListFromJson(final Map<String, dynamic>? json) {
  final jsonValue = json?.values;

  if (jsonValue != null && jsonValue.isNotEmpty) {
    final jsonLocalization = jsonValue.toList().first;
    if (jsonLocalization is String) {
      return jsonLocalization;
    }
  }

  return null;
}