getResponse method

  1. @override
Future<String?> getResponse({
  1. required String prompt,
})
override

Implementation

@override
Future<String?> getResponse({required String prompt}) async {
  if (_initCompleter.isCompleted) {
    try {
      return await methodChannel.invokeMethod<String>('getGemmaResponse', {'prompt': prompt});
    } on PlatformException catch (e) {
      throw Exception('Platform error: ${e.message}');
    } catch (e) {
      throw Exception('Error: $e');
    }
  } else {
    throw Exception('Gemma is not initialized yet');
  }
}