getJsonSetter method Null safety

MethodMirror? getJsonSetter(
  1. String? name,
  2. [dynamic scheme]
)

Implementation

MethodMirror? getJsonSetter(String? name, [dynamic scheme]) {
  MethodMirror? result;
  try {
    result =
        classMirror.declarations.values.firstWhere((DeclarationMirror dm) {
      String? returnType;
      try {
        returnType = dm is MethodMirror ? dm.returnType.simpleName : null;
      } catch (error) {
        returnType = null;
      }
      return dm is MethodMirror &&
          !dm.isPrivate &&
          !dm.isConstructor &&
          returnType == 'void' &&
          getDeclarationMeta(dm, scheme) != null &&
          getDeclarationMeta(dm, scheme)!.name == name;
    }) as MethodMirror?;
  } catch (error) {
    result = null;
  }
  return result;
}