import 'package:flutter/services.dart'; class NativeBridge { static const MethodChannel _channel = MethodChannel('com.sinoMedCloud.bridge'); // 通用invoke static Future invoke( String method, { Map? params, }) async { try { final result = await _channel.invokeMethod( method, params ); return result; } on PlatformException catch (e) { throw NativeBridgeException( code: e.code, message: e.message ?? 'Unknown error', ); } } } class NativeBridgeException implements Exception { final String code; final String message; NativeBridgeException({ required this.code, required this.message, }); @override String toString() => '[$code] $message'; }