fromJsonStringOrNull static method

FieldModel? fromJsonStringOrNull(
  1. String? jsonString
)

Constructs a new instance of FieldModel, from jsonString, which must be a valid JSON String. Returns null if jsonString is null or if the conversion fails.

Implementation

static FieldModel? fromJsonStringOrNull(
  String? jsonString,
) {
  try {
    if (jsonString!.isNotEmpty) {
      final decoded = letMapOrNull<String, dynamic>(jsonDecode(jsonString));
      return FieldModel.fromJson(decoded);
    } else {
      return FieldModel.assertRequired();
    }
  } catch (_) {
    return null;
  }
}