A sophisticated machine learning-powered system that automatically resolves versioning issues in Flutter projects' pubspec.yaml files, ensures flutter pub get completes successfully, and guarantees successful project builds.
- Intelligent Dependency Analysis: Advanced parsing and analysis of Flutter project dependencies
- Machine Learning Resolution: Uses reinforcement learning and graph neural networks to find optimal dependency versions
- Automatic Conflict Resolution: Detects and resolves version conflicts across multiple
pubspec.yamlfiles - Build Validation: Validates resolutions by running actual Flutter commands (
pub get,analyze,build) - Multi-Project Support: Handles multiple Flutter projects simultaneously
- Comprehensive Retry Logic: Intelligent retry mechanisms with exponential backoff
- Detailed Reporting: Generates comprehensive reports of resolution processes
- Preservation of Formatting: Maintains original
pubspec.yamlformatting and comments
The system consists of several integrated components:
- Dependency Analyzer (
src/analysis/): Parses and analyzes Flutter project dependencies - ML Core (
src/ml/): Machine learning algorithms for dependency resolution - Pubspec Engine (
src/core/): Advancedpubspec.yamlparsing and modification - Version Resolver (
src/ml/version_resolver.py): ML-powered version resolution algorithms - Build Validator (
src/validation/): Flutter build validation and testing - Main Integration (
main.py): Unified interface combining all components
- Python 3.11+
- Flutter SDK 3.0+
- Dart SDK 3.0+
- 4GB+ RAM (8GB recommended for large projects)
- Internet connection (for package information retrieval)
torch>=2.0.0
scikit-learn>=1.3.0
networkx>=3.0
numpy>=1.24.0
pandas>=2.0.0
matplotlib>=3.7.0
seaborn>=0.12.0
pyyaml>=6.0
ruamel.yaml>=0.18.0
semantic-version>=2.10.0
packaging>=23.0
aiohttp>=3.8.0
psutil>=5.9.0
- Clone the repository:
git clone <repository-url>
cd flutter_ml_dependency_resolver- Install Python dependencies:
pip install -r requirements.txt- Verify Flutter installation:
flutter --versionResolve dependencies for a single Flutter project:
python main.py /path/to/flutter/projectAnalyze dependencies without making changes:
python main.py /path/to/flutter/project --dry-runResolve dependencies for multiple projects:
python main.py /path/to/project1 /path/to/project2 /path/to/project3Use a custom configuration file:
python main.py /path/to/project --config config.jsonSave a detailed resolution report:
python main.py /path/to/project --report resolution_report.jsonCreate a config.json file to customize behavior:
{
"validation": {
"pub_get_timeout": 300,
"build_timeout": 600,
"analyze_timeout": 120,
"max_retries": 3,
"build_targets": ["android", "ios"],
"build_modes": ["debug"],
"run_pub_get": true,
"run_analyze": true,
"run_build": true,
"use_isolated_environment": true
},
"ml": {
"max_candidates": 10,
"optimization_goals": {
"stability": 0.4,
"compatibility": 0.3,
"security": 0.2,
"performance": 0.1
}
},
"logging": {
"level": "INFO",
"file": "resolver.log"
}
}- Parses all
pubspec.yamlfiles in the project - Builds dependency graphs with constraints
- Identifies conflicts and incompatibilities
- Uses reinforcement learning to explore version combinations
- Employs graph neural networks to understand dependency relationships
- Generates multiple candidate resolutions with confidence scores
- Applies semantic versioning rules
- Resolves transitive dependencies
- Ensures compatibility across all packages
- Creates isolated test environments
- Runs
flutter pub get,flutter analyze, andflutter build - Validates that the resolution actually works
- Automatically retries failed operations
- Uses exponential backoff for network issues
- Learns from failures to improve future resolutions
Run the comprehensive test suite:
python tests/test_framework.pyTest with example projects:
# Simple project
python main.py examples/simple_app --dry-run
# Complex project with many dependencies
python main.py examples/complex_app --dry-run
# Project with intentional conflicts
python main.py examples/conflicted_app --dry-runThe system is optimized for performance:
- Concurrent Processing: Handles multiple projects simultaneously
- Caching: Caches package information to reduce API calls
- Incremental Analysis: Only re-analyzes changed dependencies
- Resource Monitoring: Monitors CPU and memory usage during builds
Typical performance metrics:
- Simple project (5-10 dependencies): 10-30 seconds
- Complex project (20+ dependencies): 1-3 minutes
- Large enterprise project (50+ dependencies): 3-10 minutes
Adjust machine learning parameters:
from src.ml.ml_core import MLConfig
config = MLConfig(
state_dim=256,
action_dim=200,
learning_rate=0.001,
batch_size=64,
memory_size=20000
)Use the resolver programmatically:
import asyncio
from pathlib import Path
from main import FlutterDependencyResolver
async def resolve_project():
resolver = FlutterDependencyResolver()
result = await resolver.resolve_project(Path('/path/to/project'))
print(f"Resolution successful: {result['success']}")
asyncio.run(resolve_project())Extend the build validator:
from src.validation.build_validator import BuildValidator, ValidationConfig
config = ValidationConfig(
build_targets=['android', 'ios', 'web'],
build_modes=['debug', 'release'],
run_test=True
)
validator = BuildValidator(config)-
Flutter not found:
- Ensure Flutter is in your PATH
- Check with
flutter --version
-
Permission errors:
- Run with appropriate permissions
- Check file system permissions
-
Network timeouts:
- Increase timeout values in configuration
- Check internet connectivity
-
Memory issues:
- Reduce
max_concurrentparameter - Increase system memory
- Reduce
Enable verbose logging:
python main.py /path/to/project --verboseCheck logs for detailed error information:
tail -f resolver.log- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Flutter team for the excellent framework
- PyTorch team for machine learning capabilities
- The open-source community for various dependencies
For support and questions:
- Create an issue on GitHub
- Check the documentation
- Review the example projects
Note: This tool modifies your pubspec.yaml files. Always use version control and test thoroughly before deploying to production.