getJsonConstructor method Null safety

MethodMirror? getJsonConstructor(
  1. [dynamic scheme]
)

Implementation

MethodMirror? getJsonConstructor([dynamic scheme]) {
  MethodMirror? result;
  try {
    result = classMirror!.declarations.values
        .firstWhereOrNull((DeclarationMirror dm) {
      return !dm.isPrivate &&
          dm is MethodMirror &&
          dm.isConstructor &&
          hasConstructorMeta(dm, scheme) != null;
    }) as MethodMirror?;
  } catch (error) {
    result = null;
  }

  return result ??
      classMirror!.declarations.values
          .firstWhereOrNull((DeclarationMirror dm) {
        return !dm.isPrivate && dm is MethodMirror && dm.isConstructor;
      }) as MethodMirror?;
}