I am not getting empty "" response from Gemini and when I add Try Catch and Throw code to source code it throws below error:
Error Message:
TypeError: Instance of '_JsonMap': type '_JsonMap' is not a subtype of type 'String'
handle gemini error: TypeError: null: type 'Null' is not a subtype of type 'String'
Error
dart:sdk_internal 12006:11 throw_
dart:sdk_internal 23004:15 _failedAsCheck
dart:sdk_internal 22990:14
Cause:
Through debugging and adding try-catch blocks to the Gemini Flutter code, I discovered that the issue is within the integrated Dio library in Gemini Flutter.
Solution:
The current version of Dio used by Gemini Flutter is outdated. I recommend upgrading to the latest version of Dio. I have tested this upgrade and found no impact on the current source code of Gemini Flutter.
Update that when I use Gemini Flutter library with latest Dio version, so far I have not encountered the same error again.
Error Description
Issue:
When using the API call:
with the
post
function utilizing Dio multiple times:Below is the source code of the gemini_service.dart file
I am not getting empty "" response from Gemini and when I add Try Catch and Throw code to source code it throws below error:
Error Message:
Cause:
Through debugging and adding try-catch blocks to the Gemini Flutter code, I discovered that the issue is within the integrated Dio library in Gemini Flutter.
Solution:
The current version of Dio used by Gemini Flutter is outdated. I recommend upgrading to the latest version of Dio. I have tested this upgrade and found no impact on the current source code of Gemini Flutter. Update that when I use Gemini Flutter library with latest Dio version, so far I have not encountered the same error again.