Skip to content

image response problem #45

@zione-kushwaha

Description

@zione-kushwaha

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions