Skip to main content
Glama

flutter_fix_common_issues

Fix common Flutter development issues by automatically running clean, pub get, pod install, gradle sync, and cache invalidation commands in your project directory.

Instructions

Auto-fix common issues: clean, pub get, pod install, gradle sync, invalidate caches

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdYesWorking directory (Flutter project root)
deepNoPerform deep cleaning (slower but more thorough)

Implementation Reference

  • Registration of the 'flutter_fix_common_issues' tool including inline schema and handler implementation
    tools.set('flutter_fix_common_issues', {
      name: 'flutter_fix_common_issues',
      description: 'Auto-fix common issues: clean, pub get, pod install, gradle sync, invalidate caches',
      inputSchema: {
        type: 'object',
        properties: {
          cwd: {
            type: 'string',
            description: 'Working directory (Flutter project root)'
          },
          deep: {
            type: 'boolean',
            description: 'Perform deep cleaning (slower but more thorough)',
            default: false
          }
        },
        required: ['cwd']
      },
      handler: async (args: any) => {
        const fixes = [];
        
        try {
          // Step 1: Flutter clean
          const cleanResult = await flutterTools.get('flutter_clean').handler({ cwd: args.cwd });
          fixes.push({ step: 'flutter_clean', ...cleanResult });
          
          // Step 2: Flutter pub get
          const pubResult = await flutterTools.get('flutter_pub_get').handler({ cwd: args.cwd });
          fixes.push({ step: 'flutter_pub_get', ...pubResult });
          
          // Step 3: iOS pod install (if on macOS)
          if (process.platform === 'darwin') {
            try {
              const { stdout } = await processExecutor.execute(
                'pod',
                ['install'],
                { cwd: `${args.cwd}/ios` }
              );
              fixes.push({ step: 'pod_install', success: true, data: stdout });
            } catch (e) {
              fixes.push({ step: 'pod_install', success: false, error: 'Pod install failed' });
            }
          }
          
          // Step 4: Deep clean if requested
          if (args.deep) {
            // Remove build directories
            await processExecutor.execute('rm', ['-rf', 'build'], { cwd: args.cwd });
            await processExecutor.execute('rm', ['-rf', '.dart_tool'], { cwd: args.cwd });
            await processExecutor.execute('rm', ['-rf', '.packages'], { cwd: args.cwd });
            
            // Android specific
            await processExecutor.execute('./gradlew', ['clean'], { cwd: `${args.cwd}/android` });
            
            // iOS specific
            if (process.platform === 'darwin') {
              await processExecutor.execute('rm', ['-rf', 'ios/Pods'], { cwd: args.cwd });
              await processExecutor.execute('rm', ['-rf', `${process.env.HOME}/Library/Developer/Xcode/DerivedData`], {});
            }
            
            fixes.push({ step: 'deep_clean', success: true });
          }
          
          return {
            success: true,
            data: {
              fixes,
              message: 'Common issues fixed successfully'
            }
          };
        } catch (error) {
          return {
            success: false,
            error: error instanceof Error ? error.message : String(error),
            data: { fixes }
          };
        }
      }
    });
  • The handler function executes the tool logic: flutter clean, pub get, conditional pod install, and optional deep cleaning with rm and gradlew clean.
    handler: async (args: any) => {
      const fixes = [];
      
      try {
        // Step 1: Flutter clean
        const cleanResult = await flutterTools.get('flutter_clean').handler({ cwd: args.cwd });
        fixes.push({ step: 'flutter_clean', ...cleanResult });
        
        // Step 2: Flutter pub get
        const pubResult = await flutterTools.get('flutter_pub_get').handler({ cwd: args.cwd });
        fixes.push({ step: 'flutter_pub_get', ...pubResult });
        
        // Step 3: iOS pod install (if on macOS)
        if (process.platform === 'darwin') {
          try {
            const { stdout } = await processExecutor.execute(
              'pod',
              ['install'],
              { cwd: `${args.cwd}/ios` }
            );
            fixes.push({ step: 'pod_install', success: true, data: stdout });
          } catch (e) {
            fixes.push({ step: 'pod_install', success: false, error: 'Pod install failed' });
          }
        }
        
        // Step 4: Deep clean if requested
        if (args.deep) {
          // Remove build directories
          await processExecutor.execute('rm', ['-rf', 'build'], { cwd: args.cwd });
          await processExecutor.execute('rm', ['-rf', '.dart_tool'], { cwd: args.cwd });
          await processExecutor.execute('rm', ['-rf', '.packages'], { cwd: args.cwd });
          
          // Android specific
          await processExecutor.execute('./gradlew', ['clean'], { cwd: `${args.cwd}/android` });
          
          // iOS specific
          if (process.platform === 'darwin') {
            await processExecutor.execute('rm', ['-rf', 'ios/Pods'], { cwd: args.cwd });
            await processExecutor.execute('rm', ['-rf', `${process.env.HOME}/Library/Developer/Xcode/DerivedData`], {});
          }
          
          fixes.push({ step: 'deep_clean', success: true });
        }
        
        return {
          success: true,
          data: {
            fixes,
            message: 'Common issues fixed successfully'
          }
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : String(error),
          data: { fixes }
        };
      }
    }
  • Input schema defining cwd (required) and optional deep boolean flag.
    inputSchema: {
      type: 'object',
      properties: {
        cwd: {
          type: 'string',
          description: 'Working directory (Flutter project root)'
        },
        deep: {
          type: 'boolean',
          description: 'Perform deep cleaning (slower but more thorough)',
          default: false
        }
      },
      required: ['cwd']
    },
  • Metadata registration in TOOL_REGISTRY providing category, platform, requirements, and performance info for the tool.
    'flutter_fix_common_issues': {
      name: 'flutter_fix_common_issues',
      category: ToolCategory.ESSENTIAL,
      platform: 'flutter',
      requiredTools: [RequiredTool.FLUTTER],
      description: 'Auto-fix common issues: clean, pub get, pod install, gradle sync, invalidate caches',
      safeForTesting: false,
      performance: { expectedDuration: 60000, timeout: 300000 }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cristianoaredes/mcp-mobile-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server