flutter_clean
Clean Flutter build cache and generated files to resolve build issues and free up disk space in your Flutter project directory.
Instructions
Clean Flutter build cache and generated files
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | Yes | Working directory (Flutter project root) |
Implementation Reference
- src/tools/flutter.ts:798-823 (handler)The handler function executes 'flutter clean' after validating the cwd input and confirming it's a Flutter project. It returns success status, output, and execution details.handler: async (args: any) => { const validation = FlutterCleanSchema.safeParse(args); if (!validation.success) { throw new Error(`Invalid request: ${validation.error.message}`); } const { cwd } = validation.data; // Validate that it's a Flutter project await validateFlutterProject(cwd); const result = await processExecutor.execute('flutter', ['clean'], { cwd, timeout: 120000, // 2 minutes timeout for clean }); return { success: true, data: { projectPath: cwd, exitCode: result.exitCode, output: result.stdout, duration: result.duration, }, }; }
- src/tools/flutter.ts:104-111 (schema)Zod schema used internally by the handler to validate the 'cwd' parameter.* Zod validation schema for flutter_clean tool. * * @type {z.ZodObject} * @property {string} cwd - Working directory (Flutter project root) */ const FlutterCleanSchema = z.object({ cwd: z.string().min(1), });
- src/tools/flutter.ts:787-824 (registration)The tool registration in createFlutterTools function, defining name, description, inputSchema, and attaching the handler.// Flutter Clean - Clean build cache tools.set('flutter_clean', { name: 'flutter_clean', description: 'Clean Flutter build cache and generated files', inputSchema: { type: 'object', properties: { cwd: { type: 'string', minLength: 1, description: 'Working directory (Flutter project root)' } }, required: ['cwd'] }, handler: async (args: any) => { const validation = FlutterCleanSchema.safeParse(args); if (!validation.success) { throw new Error(`Invalid request: ${validation.error.message}`); } const { cwd } = validation.data; // Validate that it's a Flutter project await validateFlutterProject(cwd); const result = await processExecutor.execute('flutter', ['clean'], { cwd, timeout: 120000, // 2 minutes timeout for clean }); return { success: true, data: { projectPath: cwd, exitCode: result.exitCode, output: result.stdout, duration: result.duration, }, }; } });
- src/tools/flutter.ts:158-169 (helper)Helper function validateFlutterProject used in the handler to ensure the cwd is a valid Flutter project by checking pubspec.yaml.const validateFlutterProject = async (cwd: string): Promise<void> => { const pubspecPath = path.join(cwd, 'pubspec.yaml'); try { await fs.access(pubspecPath); const pubspecContent = await fs.readFile(pubspecPath, 'utf8'); if (!pubspecContent.includes('flutter:')) { throw new Error(`Directory does not appear to be a Flutter project. No flutter section found in ${pubspecPath}`); } } catch { throw new Error(`pubspec.yaml not found. Flutter project must contain pubspec.yaml at: ${pubspecPath}`); } };