Comprehensive guidance on Flutter platform integration including platform channels, native code integration, plugin development, and platform views. Use when working with platform-specific features, creating plugins, or integrating native Android/iOS code with Flutter applications.
From flutter-corenpx claudepluginhub aaronbassett/agent-foundry --plugin flutter-coreThis skill uses the workspace's default tool permissions.
examples/custom-plugin.mdexamples/native-features.mdreferences/android-integration.mdreferences/ios-integration.mdreferences/platform-channels.mdreferences/platform-views.mdreferences/plugin-development.mdSearches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides agent creation for Claude Code plugins with file templates, frontmatter specs (name, description, model), triggering examples, system prompts, and best practices.
This skill provides comprehensive guidance on Flutter platform integration, covering platform channels, native code integration, plugin development, and platform views. Use this skill when working with platform-specific features, creating plugins, or integrating native Android/iOS code with Flutter applications.
Use this skill when:
Flutter's platform integration system enables you to build cross-platform apps while accessing platform-specific functionality when needed. This skill covers the complete spectrum from simple method calls to complex native integrations.
Platform Channels: Asynchronous message-passing channels between Flutter (Dart) and native code:
Native Integration: Three primary approaches:
Plugin Architecture: Reusable packages combining Dart APIs with platform-specific implementations:
The typical platform integration flow:
┌─────────────────────────────────────────────────────┐
│ Flutter (Dart) │
│ ┌──────────────────────────────────────────────┐ │
│ │ Your Flutter Widget/App │ │
│ └────────────────┬─────────────────────────────┘ │
│ │ │
│ ┌────────────────▼─────────────────────────────┐ │
│ │ MethodChannel / EventChannel / FFI │ │
│ └────────────────┬─────────────────────────────┘ │
└───────────────────┼─────────────────────────────────┘
│ Asynchronous Messages
┌───────────────────▼─────────────────────────────────┐
│ Platform-Specific Code │
│ ┌──────────────────┐ ┌──────────────────┐ │
│ │ Android │ │ iOS │ │
│ │ (Kotlin/Java) │ │ (Swift/Obj-C) │ │
│ └──────────────────┘ └──────────────────┘ │
│ │
│ Platform APIs: Camera, Location, Battery, etc. │
└─────────────────────────────────────────────────────┘
1. Asynchronous by Design: All platform channel communications are asynchronous to maintain UI responsiveness. Never block the UI thread waiting for native responses.
2. Type-Safe Communication: Use StandardMessageCodec for automatic type conversion between Dart and native types, or leverage Pigeon for compile-time type safety.
3. Main Thread Constraint: Channel method handlers must execute on the platform's main thread (UI thread). Use dispatchers/handlers to switch threads when needed.
4. Error Handling: Always implement robust error handling on both sides:
PlatformException with try-catch blocks5. Cross-Platform Consistency: Design APIs that work consistently across platforms while respecting platform-specific conventions and limitations.
This skill includes comprehensive reference documentation:
This skill includes complete working examples:
flutter pub publish --dry-runcom.example.app/battery)PlatformException and provide helpful error messages// Dart
final result = await platform.invokeMethod('getBatteryLevel');
// Dart
final result = await platform.invokeMethod('processImage', {
'path': imagePath,
'quality': 85,
});
// Dart
final stream = EventChannel('com.example/events').receiveBroadcastStream();
stream.listen((event) => handleEvent(event));
// Dart
try {
final result = await platform.invokeMethod('riskyOperation');
} on PlatformException catch (e) {
print('Error: ${e.code} - ${e.message}');
}
// Dart
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return AndroidView(viewType: 'my-view');
case TargetPlatform.iOS:
return UiKitView(viewType: 'my-view');
default:
throw UnsupportedError('Platform not supported');
}
MissingPluginException: Plugin not registered properly
flutter clean and rebuildPlatformException: Native code threw an error
Type Mismatch: Data not serializing correctly
Threading Issues: Crashes or unresponsive UI
Platform View Performance: Laggy animations
Create custom codecs for complex data types not supported by StandardMessageCodec.
Use BackgroundIsolateBinaryMessenger to invoke platform channels from isolates other than the root isolate.
Split plugins into app-facing interface, platform interface, and platform implementations for modularity and maintainability.
Choose FFI for synchronous, low-level C/C++ library access. Choose platform channels for platform APIs and async operations.
Implement features on some platforms while gracefully degrading on others. Document platform support clearly.
Flutter's platform integration system provides a powerful bridge between cross-platform Dart code and native platform capabilities. Whether you're calling a simple native API, creating a comprehensive plugin, or embedding native UI components, the patterns and practices in this skill will guide you toward robust, maintainable implementations.
Start with platform channels for most use cases, leverage Pigeon for type safety when complexity grows, and consider FFI for direct C/C++ library access. Always prioritize error handling, documentation, and cross-platform consistency to create excellent developer experiences.
For specific implementation details, consult the reference documentation and examples provided in this skill.