faithoflifedev / google_vision_workspace

Integrates Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications.
MIT License
20 stars 8 forks source link

type 'Null' is not a subtype of type 'String' in type cast #26

Closed priyankgandhi0 closed 1 week ago

priyankgandhi0 commented 1 week ago

File imageFile = File(path); List<int> imageBytes = imageFile.readAsBytesSync(); var response = await GoogleVision().withApiKey(Keys.googleVisionApi).image.detection( JsonImage.fromBuffer( Uint8List.fromList( await imageFile.readAsBytes(), ).buffer, ), AnnotationType.webDetection, maxResults: 1, );

I am facing below issue from above Code

#0      _$WebEntityFromJson (package:google_vision/src/model/web_entity.g.dart:12:40)
#1      new WebEntity.fromJson (package:google_vision/src/model/web_entity.dart:27:7)
#2      _$WebDetectionFromJson.<anonymous closure> (package:google_vision/src/model/web_detection.g.dart:11:34)
#3      MappedListIterable.elementAt (dart:_internal/iterable.dart:425:31)
#4      ListIterator.moveNext (dart:_internal/iterable.dart:354:26)
#5      new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#6      new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#7      new List.of (dart:core-patch/array_patch.dart:39:18)
#8      ListIterable.toList (dart:_internal/iterable.dart:224:7)
#9      _$WebDetectionFromJson (package:google_vision/src/model/web_detection.g.dart:12:12)
#10     new WebDetection.fromJson (package:google_vision/src/model/web_detection.dart:40:7)
#11     _$AnnotateImageResponseFromJson (package:google_vision/src/model/annotate_image_response.g.dart:50:26)
#12     new AnnotateImageResponse.fromJson (package:google_vision/src/model/annotate_image_response.dart:153:7)
#13     _$BatchAnnotateImagesResponseFromJson.<anonymous closure> (package:google_vision/src/model/batch_annotate_images_response.g.dart:13:45)
#14     MappedListIterable.elementAt (dart:_internal/iterable.dart:425:31)
#15     ListIterator.moveNext (dart:_internal/iterable.dart:354:26)
#16     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)
#17     new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)
#18     new List.of (dart:core-patch/array_patch.dart:39:18)
#19     ListIterable.toList (dart:_internal/iterable.dart:224:7)
#20     _$BatchAnnotateImagesResponseFromJson (package:google_vision/src/model/batch_annotate_images_response.g.dart:14:12)
#21     new BatchAnnotateImagesResponse.fromJson (package:google_vision/src/model/batch_annotate_images_response.dart:19:7)
#22     _ImagesClient.annotate (package:google_vision/src/provider/images.g.dart:57:44)
<asynchronous suspension>
#23     GoogleVisionImage.detection (package:google_vision/src/google_vision_image.dart:40:32)
<asynchronous suspension>
#24     Image2Controller.convertImageToGoogleVision (package:geminai/modules/views/image_screen/image2/image2_controller.dart:142:11)
<asynchronous suspension>
#25     _ImageScreen2State.sendMessage.<anonymous closure> (package:geminai/modules/views/image_screen/image2/image_screen2.dart:395:36)
<asynchronous suspension>
faithoflifedev commented 1 week ago

Hello @priyankgandhi0,

The error you are seeing is not generated by the package, there are problems with your code. Take a look at the web_detection example here - https://github.com/faithoflifedev/google_vision_workspace/blob/main/packages/google_vision/example/web_detection.dart for some tips