How anand-cureocity/anura_flutter works
Project type and purpose
• This is a Federated Flutter Plugin repository (“anura_flutter”) that provides a single Dart API surface, exposed to Flutter apps.
• Internally it uses the federated‐plugin pattern: a platform interface package plus separate Android and iOS implementation packages.
• There’s also an example Flutter application (under anura_flutter/example) used for integration tests.
File structure and README
• Top‐level packages:
– anura_flutter (main plugin + example)
– anura_flutter_platform_interface (defines the Dart interface and method‐channel contract)
– anura_flutter_android (Android implementation in Kotlin + bundled AARs)
– anura_flutter_ios (iOS implementation in Swift + xcframeworks)
• Example app under anura_flutter/example uses Fluttium for integration tests.
• CI workflows configured under .github/workflows to build/test all packages on Android, iOS, and web.
Main components
A. Flutter Application (Example)
– Dart UI code calls into anura_flutter plugin API.
B. Dart Plugin Package (anura_flutter/lib)
– Exposes AnuraFlutter class methods.
– Delegates calls to anura_flutter_platform_interface.
C. Platform Interface Package
– Defines abstract methods and MethodChannelAnuraFlutter default implementation.
– Ensures both Android and iOS implementations adhere to the same contract.
D. MethodChannel / Platform Channel
– The runtime bridge over which Dart and native code communicate.
E. Android Implementation Package
– Kotlin classes (e.g. AnuraFlutterPlugin.kt, AnuraScannerActivity.kt).
– Bundled native SDKs (.aar files: Anura Core SDK, OpenCV, DFX extras, DFX SDK).
– Uses Android View, camera, etc., to perform scanning, then returns results via platform channel.
F. iOS Implementation Package
– Swift classes (AnuraFlutterPlugin.swift, networking, measurement delegate).
– Bundled xcframeworks (AnuraCore, FaceMesh, libdfx).
– Uses AVFoundation/CoreML/MediaPipe under the hood, responds via MethodChannel.
G. Native SDK Frameworks
– On Android: AARs that encapsulate native C++/Java code.
– On iOS: xcframeworks containing Swift/C++/C code, models.
H. CI/CD workflows
– GitHub Actions build/test each package on multiple platforms (Android, iOS).
I. Integration Tests (Fluttium)
– YAML flows drive the example app to validate end-to-end plugin behavior.
Relationships and data flow
1. Flutter UI (Example) → calls Dart API in anura_flutter package
2. anura_flutter → calls platform interface API
3. Platform interface default → uses MethodChannel to invoke native method
4. MethodChannel → dispatches to Android or iOS host code
5. Native implementation → invokes underlying AnuraCore/FaceMesh/DFX SDK for scanning
6. SDK → returns measurement/scanned data back up to host implementation
7. Host implementation → returns data via MethodChannel result callback to Dart
8. Dart receives result → propagates back to Flutter UI
9. Integration Tests drive the Flutter UI and assert behaviors.
Architectural patterns and principles
• Federated plugin architecture: isolates platform interface from platform implementations.
• Clean separation of concerns: Dart code does not depend directly on platform SDKs.
• Single source of truth for API: only the platform interface defines method signatures.
• CI-as-documentation: GitHub Actions workflows show how builds/tests run.
Technologies and frameworks
• Dart & Flutter (UI + plugin layer)
• MethodChannel (Flutter platform channel)
• Kotlin + Android SDK + AAR artifacts
• Swift + iOS frameworks + AVFoundation / CoreML
• GitHub Actions (CI/CD)
• Fluttium (integration testing)