extractInformation method
Implementation
@override
Future<Map<String, dynamic>> extractInformation(
String text, {
String? sessionId,
List<String>? fields,
}) async {
if (text.trim().isEmpty) {
throw AppleFoundationException(
'Text cannot be empty',
code: 'INVALID_TEXT',
);
}
try {
final Map<dynamic, dynamic>? result =
await _invokeMethodWithTimeout<Map<dynamic, dynamic>>(
'extractInformation',
{
'text': text,
if (sessionId != null) 'sessionId': sessionId,
if (fields != null && fields.isNotEmpty) 'fields': fields,
},
);
if (result == null) {
throw AppleFoundationException(
'Received null response from native layer',
code: 'NULL_RESPONSE',
);
}
return Map<String, dynamic>.from(result);
} catch (e) {
_logError('extractInformation', e);
throw AppleFoundationException(
'Failed to extract information: ${e.toString()}',
code: 'EXTRACT_INFORMATION_FAILED',
details: {'sessionId': sessionId, 'fields': fields},
);
}
}