Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image response problem #45

Open
zione-kushwaha opened this issue Dec 11, 2024 · 1 comment
Open

image response problem #45

zione-kushwaha opened this issue Dec 11, 2024 · 1 comment

Comments

@zione-kushwaha
Copy link

i am not getting response from for image only getting instance of image part

Future _processImage() async {
if (_selectedImage == null) {
setState(() {
_response = 'No image selected';
});
return;
}

try {
  final bytes = await _selectedImage!.readAsBytes();

  Gemini.instance.textAndImage(
    text: 'Analyze this image and describe its content.',
    images: [bytes],
  ).then((response) {
    final parts = response?.content?.parts;
    final lastText = parts ?? 'No text content found';

    setState(() {
      _response = lastText.toString();
    });
  }).catchError((error) {
    setState(() {
      _response = 'Error: $error';
    });
  });
} catch (e) {
  setState(() {
    _response = 'Error: $e';
  });
}

}

i tried using that final lastText = parts ?? 'No text content found';.......parts.text but also there is error saying in text ........now only i am getting response as instance of textPart.....how to solve this problem

@ArpitAswal
Copy link

Yes, I am also facing the same issue. The compiler says, the getter 'text' isn't defined for the type 'Part'.

problem link: #45 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants