flutter_env_doctor 0.0.1
flutter_env_doctor: ^0.0.1 copied to clipboard
A Dart CLI package to diagnose and auto-fix common Android build issues in Flutter projects. Resolves Gradle, Kotlin, and Android SDK configuration problems.
Flutter Environment Doctor #
A Dart CLI package to diagnose and auto-fix common Android build issues in Flutter projects.
Note: This is an initial version, and we are actively working on improvements for future releases.
This tool helps Flutter developers identify and fix configuration issues in the Android side of their Flutter projects, including problems with Gradle, Android Gradle Plugin (AGP), Kotlin versions, and Android SDK settings.
Features #
-
Diagnose common Android build issues:
- Inspect gradle-wrapper.properties, root build.gradle, and app/build.gradle
- Validate Gradle, AGP, and Kotlin versions
- Check compileSdkVersion, minSdkVersion, targetSdkVersion
- Verify jvmTarget configuration
-
Repair (Automated):
- Apply suggested fixes to build files
- Interactive fixing with confirmation for each issue
- Dry-run mode to preview changes
- Backup option for safe modifications
Getting Started #
Installation #
dart pub global activate flutter_env_doctor
Or add it to your pubspec.yaml as a dev dependency:
dev_dependencies:
flutter_env_doctor: ^0.0.1
Usage #
CLI Commands #
The tool offers two main commands:
- Check mode - Diagnose issues without fixing them:
flutter_env_doctor check
- Fix mode - Diagnose and interactively repair issues:
flutter_env_doctor fix
Fix Mode Options #
--dry-run(-d): Show changes without applying them--backup(-b): Backup files before modification--apply-all(-a): Apply all fixes non-interactively (use with caution)
Examples #
# Check for issues only
flutter_env_doctor check
# Fix issues interactively with backups
flutter_env_doctor fix --backup
# Preview fixes without applying them
flutter_env_doctor fix --dry-run
# Apply all fixes automatically (non-interactive)
flutter_env_doctor fix --apply-all
Using as a Library #
You can also use the package as a library in your Dart code:
import 'package:flutter_env_doctor/flutter_env_doctor.dart';
Future<void> main() async {
final doctor = FlutterEnvDoctor(
projectDir: '/path/to/flutter/project',
backup: true,
dryRun: false,
);
// Check for issues
final issues = await doctor.check();
// Print summary
doctor.printSummary();
// Fix issues automatically
await doctor.fix(applyAll: true);
}
Which Issues Are Detected? #
The tool checks for these common issues:
-
Gradle Configuration:
- Outdated Gradle wrapper version
- Outdated Android Gradle Plugin version
- Incompatible/missing compileSdkVersion
- Too low minSdkVersion
- Outdated targetSdkVersion
-
Kotlin Configuration:
- Outdated Kotlin version
- Usage of deprecated Kotlin Android Extensions plugin
Compatibility #
This tool is compatible with:
- Flutter 3.0.0 or higher
- Dart 3.0.0 or higher
License #
This project is licensed under the MIT License - see the LICENSE file for details.