Flutter + ARCore/ARKit: Building a Cross-Platform Spatial AR App
Flutter can provide a shared application layer while ARCore and ARKit handle platform-specific spatial tracking.
Architecture
Flutter
↓
Spatial AR Interface
↙ ↘
Android iOS
ARCore ARKit
↘ ↙
Spatial State
↓
Flutter UI
Create a Common API
abstract class SpatialArService {
Future<void> start();
Future<void> stop();
Future<void> addAnchor({
required double x,
required double y,
required double z,
});
}
The Android implementation can use ARCore and the iOS implementation can use ARKit.
Spatial Concepts
An AR application commonly works with:
- camera pose
- planes
- anchors
- hit testing
- depth
- world coordinates
- tracking state
Do not assume that coordinate conventions are identical across platforms. Put conversions in a dedicated spatial layer.
Anchors
Physical Surface
↓
Hit Test
↓
3D Position
↓
Anchor
↓
Virtual Object
Anchors allow virtual content to remain associated with real-world locations.
Platform Channels
Flutter can expose a small contract:
startSession
stopSession
addAnchor
removeAnchor
setTrackingMode
For continuous events, use an event stream or plugin API:
trackingChanged
planeDetected
anchorAdded
trackingLost
Avoid exposing the entire native AR API to Dart.
State Management
A BLoC or controller can model:
sealed class ArState {}
class ArInitial extends ArState {}
class ArStarting extends ArState {}
class ArReady extends ArState {}
class ArTrackingLost extends ArState {}
class ArError extends ArState {
final String message;
ArError(this.message);
}
Performance
High-frequency AR rendering should remain close to the native AR engine.
Avoid:
Native AR → hundreds of Dart events → huge rebuilds
Prefer:
Native AR → native rendering
↓
compact state/events
↓
Flutter
Tracking Loss
Tracking can degrade because of:
- poor lighting
- blank surfaces
- rapid movement
- camera obstruction
- insufficient visual features
Provide useful feedback such as:
Tracking lost
Move the camera slowly
Cross-Platform Testing
Test both ecosystems independently:
Android → different ARCore devices
iOS → different ARKit devices
Equivalent APIs do not guarantee identical behavior.
Conclusion
The key to cross-platform spatial AR is a stable Flutter abstraction with native AR implementations underneath it. Keep performance-sensitive spatial processing close to ARCore and ARKit while Flutter manages the broader application.
Useful Links
SDK Flutter: https://github.com/v-modal/vmodal_sdk_flutter
SDK Android: https://github.com/v-modal/vmodal_sdk_android
Discord: https://discord.gg/K72z28KUx
Top comments (0)