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

No output when Loading images from camera #4

Open
KanyantaM opened this issue Jan 4, 2024 · 0 comments
Open

No output when Loading images from camera #4

KanyantaM opened this issue Jan 4, 2024 · 0 comments

Comments

@KanyantaM
Copy link

When I use the textAndImage method to get a response and the images are form the camera, I am not getting a response from Gemini.

ChatInputBox(
          controller: controller,
          onClickCamera: () async {
            showDialog(
                context: context,
                builder: ((context) {
                  return AlertDialog(
                    title: const Text('Image Selection'),
                    content: const Text(
                        'Do you want to use your camera or select an image from the gallery?'),
                    actions: [
                      TextButton(
                        onPressed: () async {
                          Navigator.pop(context);
                          // Capture a photo.
                          final XFile? photo = await picker.pickImage(
                              source: ImageSource.camera);

                          if (photo != null) {
                            photo.readAsBytes().then((value) => setState(() {
                                  selectedImage = value;
                                }));
                          }
                        },
                        child: const Text('Camera'),
                      ),
                      TextButton(
                        onPressed: () async {
                          Navigator.pop(context);
                          // Capture a photo.
                          final XFile? photo = await picker.pickImage(
                              source: ImageSource.gallery);

                          if (photo != null) {
                            photo.readAsBytes().then((value) => setState(() {
                                  selectedImage = value;
                                }));
                          }
                        },
                        child: const Text('Gallery'),
                      ),
                    ],
                  );
                }));
          },
          onSend: () async {
            if (controller.text.isNotEmpty) {
              final searchedText = controller.text;
              if (selectedImage == null) {
                chats.add(
                    Content(role: 'user', parts: [Parts(text: searchedText)]));
                controller.clear();
                loading = true;

                gemini.chat(chats).then((value) {
                  chats.add(Content(
                      role: 'model', parts: [Parts(text: value?.output)]));
                  loading = false;
                });
              } else {
                chats.add(
                    Content(role: 'user', parts: [Parts(text: searchedText)]));
                controller.clear();
                loading = true;

                gemini.textAndImage(
                    text: searchedText, images: [selectedImage!]).then((value) {
                  chats.add(Content(
                      role: 'model', parts: [Parts(text: value?.output)]));
                  loading = false;
                  selectedImage = null;
                });
              }
            }
          },
        ),
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

1 participant