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> events() { return _events .receiveBroadcastStream() .map((dynamic e) => Map.from(e as Map)); } Future getSdkVersion() async { return await _methods.invokeMethod('getSdkVersion') ?? 'unknown'; } /// Kicks off DJI app registration (requires a valid App Key + internet). Future registerApp() => _methods.invokeMethod('registerApp'); /// Starts scanning for a connected product (USB remote controller / Wi-Fi). Future startConnection() async { return await _methods.invokeMethod('startConnection') ?? false; } Future stopConnection() => _methods.invokeMethod('stopConnection'); Future> getProductInfo() async { final dynamic info = await _methods.invokeMethod('getProductInfo'); return Map.from(info as Map); } }