fromJsonStringOrNull static method

GenerateDartModel? fromJsonStringOrNull(
  1. String? jsonString
)
override

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

Implementation

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