import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'classify_photo_platform_interface.dart'; /// An implementation of [ClassifyPhotoPlatform] that uses method channels. class MethodChannelClassifyPhoto extends ClassifyPhotoPlatform { /// The method channel used to interact with the native platform. @visibleForTesting final methodChannel = const MethodChannel('classify_photo'); @override Future getPlatformVersion() async { final version = await methodChannel.invokeMethod('getPlatformVersion'); return version; } @override Future>?> getPhoto() async { try { print('Flutter: 调用 getPhoto 方法'); final List? result = await methodChannel.invokeMethod>( 'getPhoto', ); print('Flutter: 收到原生返回结果: $result'); if (result == null) { print('Flutter: 结果为空'); return null; } return result.map((group) => Map.from(group)).toList(); } on PlatformException catch (e) { print('Flutter: Platform Exception: ${e.message}'); rethrow; } catch (e) { print('Flutter: Error: $e'); rethrow; } } }