Add API Server (Go/PocketBase), Web App (Go BFF + Vue), Fly App (Flutter/DJI MSDK), Adobe Plugin, and Docker/Docker AIO deployment configs. Design assets and build artifacts are gitignored. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
1.5 KiB
Dart
40 lines
1.5 KiB
Dart
import 'package:flutter/services.dart';
|
|
|
|
/// Thin Dart wrapper over the native DJI Mobile SDK bridge.
|
|
///
|
|
/// Mirrors the channels defined in `DjiSdkBridge.kt`:
|
|
/// * method channel `dji_msdk/methods` for imperative calls
|
|
/// * event channel `dji_msdk/events` for the SDK's async updates
|
|
class DjiService {
|
|
static const MethodChannel _methods = MethodChannel('dji_msdk/methods');
|
|
static const EventChannel _events = EventChannel('dji_msdk/events');
|
|
|
|
/// Broadcast stream of SDK events. Each event is a map with a `type` key:
|
|
/// `registration`, `connection`, `telemetry`, `battery`, `database`, `init`.
|
|
Stream<Map<String, dynamic>> events() {
|
|
return _events
|
|
.receiveBroadcastStream()
|
|
.map((dynamic e) => Map<String, dynamic>.from(e as Map));
|
|
}
|
|
|
|
Future<String> getSdkVersion() async {
|
|
return await _methods.invokeMethod<String>('getSdkVersion') ?? 'unknown';
|
|
}
|
|
|
|
/// Kicks off DJI app registration (requires a valid App Key + internet).
|
|
Future<void> registerApp() => _methods.invokeMethod<void>('registerApp');
|
|
|
|
/// Starts scanning for a connected product (USB remote controller / Wi-Fi).
|
|
Future<bool> startConnection() async {
|
|
return await _methods.invokeMethod<bool>('startConnection') ?? false;
|
|
}
|
|
|
|
Future<void> stopConnection() =>
|
|
_methods.invokeMethod<void>('stopConnection');
|
|
|
|
Future<Map<String, dynamic>> getProductInfo() async {
|
|
final dynamic info = await _methods.invokeMethod('getProductInfo');
|
|
return Map<String, dynamic>.from(info as Map);
|
|
}
|
|
}
|