anchor.diff:  
     @override
     void visitFunctionExpression(FunctionExpression node) {
  -    if ((inConsumerBuilder || inHookBuilder) && lookingForBuilderParams) {
  -      lookingForBuilderParams = false;
  -      migrateParams(node.parameters);
  +    try {
  +      if ((inConsumerBuilder || inHookBuilder) && lookingForBuilderParams) {
  +        lookingForBuilderParams = false;
  +        migrateParams(node.parameters);
  +      }
  +    } catch (e, st) {
  +      addError('before visiting function expression $node\n$e\n$st');
       }
       super.visitFunctionExpression(node);
     }
  
positive.code: 
    @override
    void visitFunctionDeclaration(FunctionDeclaration node) {
      currentFunctionInfo = ProviderFunction(
          name: node.name.name,
          path: node.declaredElement!.declaration.location!.components.join('/'),
          line: node.name.offset);
      isProviderDependentFunction[currentFunctionInfo!] = false;
      functionDependencies[currentFunctionInfo!] = {};
      super.visitFunctionDeclaration(node);
      currentFunctionInfo = null;
    }
  
    @override
    void visitMethodDeclaration(MethodDeclaration node) {
      currentFunctionInfo = ProviderFunction(
          name: node.name.name,
          path: node.declaredElement!.declaration.location!.components.join('/'),
          line: node.name.offset);
      isProviderDependentFunction[currentFunctionInfo!] = false;
      functionDependencies[currentFunctionInfo!] = {};
      super.visitMethodDeclaration(node);
      currentFunctionInfo = null;
    }
  
negative.code:   }
  
    void migrateStateProvider(Expression expression) {
      try {
        if (expression.staticType
                ?.getDisplayString(withNullability: true)
                .contains('StateProvider') ??
            false) {
          yieldPatch('.state', expression.end, expression.end);
        }
      } catch (e, st) {
        addError(
            'when migrating state provider ${expression.toSource()}\n$e\n$st');
      }
    }
  
    void migrateStateful(String statefulName) {
      try {
        final statefulDeclaration = statefulDeclarations[statefulName];
        if (statefulDeclaration != null) {
          yieldPatch(
              'ConsumerStatefulWidget',
              statefulDeclaration.extendsClause!.superclass.offset,
              statefulDeclaration.extendsClause!.superclass.end);
          final method = statefulDeclaration.members.firstWhereOrNull((m) =>
                  m is MethodDeclaration && m.name.name.contains('createState'))
              as MethodDeclaration?;
  
          if (method != null &&
              method.returnType != null &&
              method.returnType!.toSource().contains('State<StatefulWidget>')) {
            yieldPatch('ConsumerState<ConsumerStatefulWidget>',
                method.returnType!.offset, method.returnType!.end);
          }
        } else {
          statefulNeedsMigration.add(statefulName);
        }
      } catch (e, st) {
        addError('when migrating stateful widget $statefulName\n$e\n$st');
      }
    }
  
    void migrateOnChangeFunction(String functionName) {
      try {
        final methodDecl = methodDecls[functionName];
        if (methodDecl != null && functionNeedsMigration.contains(functionName)) {
          if (methodDecl.parameters?.parameters[1] is SimpleFormalParameter) {
            final parameter =
                methodDecl.parameters!.parameters[1] as SimpleFormalParameter;
            final type =
                parameter.type!.type!.getDisplayString(withNullability: false);
            yieldPatch(
                '$type? previous,',
                methodDecl.parameters!.parameters.first.offset,
                methodDecl.parameters!.parameters[1].offset);
          } else {
            addError(
                'failed to migrate listen function ${methodDecl.parameters?.toSource()}');
          }
        } else {
          final funcDecl = functionDecls[functionName];
          if (funcDecl != null && functionNeedsMigration.contains(functionName)) {
            if (funcDecl.functionExpression.parameters?.parameters[1]
                is SimpleFormalParameter) {
              final parameter = funcDecl.functionExpression.parameters!
                  .parameters[1] as SimpleFormalParameter;
              final type =
                  parameter.type!.type!.getDisplayString(withNullability: false);
              yieldPatch(
                  '$type? previous,',
                  funcDecl.functionExpression.parameters!.parameters.first.offset,
                  funcDecl.functionExpression.parameters!.parameters[1].offset);
            } else {
              addError(
                  'failed to migrate listen function ${funcDecl.functionExpression.parameters?.toSource()}');
            }
          }
        }
      } catch (e, st) {
        addError(
            'when migrating onChangeFunction $functionName for a listener\n$e\n$st');
      }
    }
  }
  