Common pubspec.yaml Mistakes That Are Hurting Your Flutter App's Native Integration
FlutterPulseThis article was translated specially for the channel FlutterPulseYou'll find lots of interesting things related to Flutter on this channel. Don't hesitate to subscribe!🚀

Not a Medium member? No worries — you can read this article for free using my friend link!
1. Version Management Nightmares
Why This Matters?
- Native Breaking Changes: Platform-specific APIs often change between versions. Loose versioning can unexpectedly pull in updates that break native integration
- Build Failures: Mismatched versions between interdependent plugins can cause native build failures
- Runtime Crashes: Version conflicts can lead to runtime crashes when accessing native features
- CI/CD Issues: Inconsistent versioning makes automated builds unreliable
# ❌ Dangerous Approach
dependencies:
google_maps_flutter: ^2.0.0 # Could automatically update to incompatible version
location: ^4.0.0
# ✅ Safe Approach
dependencies:
google_maps_flutter: '>=2.0.0 <3.0.0' # Explicitly controlled version range
location: '>=4.0.0 <5.0.0'
Real Impact:
- A team lost 2 days debugging when
^2.0.0pulled in version 2.3.0 which required different Android permissions - Production app crashed because of mismatched native library versions
2. Platform-Specific Dependencies
Why This Matters?
- Different Platform Requirements: iOS and Android often need different versions of the same functionality
- Native Library Conflicts: Platform-specific native libraries can conflict if not properly specified
- Build Size Optimization: Unnecessary platform code increases app size
- Security Updates: Platform-specific security patches need precise version control
# ❌ Problematic Approach
dependencies:
camera: ^3.0.0
# ✅ Optimized Approach
dependencies:
camera:
platforms:
android:
package: io.flutter.plugins.camera
pluginClass: CameraPlugin
minSdkVersion: 21
ios:
pluginClass: CameraPlugin
deploymentTarget: '11.0'
Real Impact:
- Reduced app size by 30% by properly specifying platform-specific dependencies
- Eliminated crashes on older Android devices by setting correct minSdkVersion
3. Asset Management Blunders
Why This Matters?
- Build Time Impact: Including unnecessary assets increases build time
- App Size Bloat: Improper asset management can double app size
- Memory Usage: Loading unused assets wastes device memory
- Platform Optimization: Different platforms may need different asset formats
# ❌ Inefficient Approach
flutter:
assets:
- assets/ # Includes everything, even build artifacts
# ✅ Optimized Approach
flutter:
assets:
- assets/images/2.0x/
- assets/images/3.0x/
- assets/native/android/
- assets/native/ios/
platform_assets:
android:
- assets/native/android/
ios:
- assets/native/ios/
Real Impact:
- Reduced app size by 40% by removing unused assets
- Improved app launch time by 2 seconds with optimized asset loading
4. Environment Configuration Errors
Why This Matters?
- Build Stability: Wrong environment configs cause mysterious build failures
- Platform Compatibility: Different platforms need different minimum versions
- Development Efficiency: Proper configs prevent development environment issues
- Future Proofing: Correct constraints help with future upgrades
# ❌ Incomplete Configuration
environment:
sdk: ">=3.0.0 <4.0.0"
# ✅ Comprehensive Configuration
environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.10.0"
min_android_sdk: "21"
min_ios_version: "11.0"
kotlin_version: "1.8.0"
swift_version: "5.0"
Real Impact:
- Prevented 15 CI/CD failures by properly specifying environment constraints
- Saved 3 hours per developer on environment setup
5. Plugin Configuration Mistakes
Why This Matters?
- Permission Issues: Improper plugin configs lead to runtime permission failures
- Native Crashes: Wrong plugin initialization order causes crashes
- Resource Conflicts: Plugin conflicts can cause resource duplication
- Performance Impact: Incorrect plugin setup affects app performance
# ❌ Risky Configuration
dependencies:
location: ^4.0.0
permission_handler: ^8.0.0
# ✅ Robust Configuration
dependencies:
location: '>=4.0.0 <5.0.0'
permission_handler: '>=8.0.0 <9.0.0'
flutter:
plugin:
platforms:
android:
package: com.example.myapp
pluginClass: MyAppPlugin
permission:
- ACCESS_FINE_LOCATION
- CAMERA
ios:
pluginClass: MyAppPlugin
Real Impact:
- Fixed 80% of crash reports by proper plugin configuration
- Reduced ANR (Application Not Responding) rates by 60%
6. Build Configuration Issues
Why This Matters?
- Release Performance: Proper build configs affect app performance
- App Size: Build configurations impact final app size
- Debug Capability: Wrong configs can make debugging impossible
- Security: Build configurations affect app security
# ❌ Basic Configuration
flutter:
uses-material-design: true
# ✅ Optimized Configuration
flutter:
uses-material-design: true
build:
android:
proguard: true
multidex: true
target-platform: android-arm64
ios:
bitcode: true
symbols: true
deployment_target: '11.0'
Real Impact:
- Reduced release build size by 35% with proper configurations
- Improved app startup time by 40% with optimized builds
7. Development Dependencies
Why This Matters?
- Testing Accuracy: Proper dev dependencies ensure reliable tests
- CI/CD Efficiency: Correct configs make automation reliable
- Development Speed: Right tools improve development velocity
- Quality Assurance: Testing tools affect code quality
# ❌ Basic Testing Setup
dev_dependencies:
flutter_test:
sdk: flutter
# ✅ Comprehensive Testing Setup
dev_dependencies:
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
flutter_driver:
sdk: flutter
mockito: ^5.0.0
build_runner: ^2.0.0
flutter_native_splash: ^2.0.0
Real Impact:
- Reduced testing time by 50% with proper test configurations
- Caught 90% of native integration issues before production

A message from our Founder
Hey, Sunil here. I wanted to take a moment to thank you for reading until the end and for being a part of this community.
Did you know that our team run these publications as a volunteer effort to over 3.5m monthly readers? We don't receive any funding, we do this to support the community. ❤️
If you want to show some love, please take a moment to follow me on LinkedIn, TikTok, Instagram. You can also subscribe to our weekly newsletter.
And before you go, don't forget to clap and follow the writer️!