'E/flutter (24259): Unhandled Exception: Bad state: Cannot set the body fields of a Request with content-type "application/json"

var filterQuerry =algolia.instance.index(indexName.value.toString()).facetQuery("cast");

I am trying to use facetQuerry method of Algolia packega but I am facing an error below,Above is the mentioned code that is showing error

E/flutter (24259): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Bad state: Cannot set the body fields of a Request with content-type "application/json".
E/flutter (24259): #0      Request.bodyFields= (package:http/src/request.dart:133:7)
E/flutter (24259): #1      BaseClient._sendUnstreamed (package:http/src/base_client.dart:87:17)
E/flutter (24259): #2      BaseClient.post (package:http/src/base_client.dart:32:7)
E/flutter (24259): #3      post.<anonymous closure> (package:http/http.dart:69:16)
E/flutter (24259): #4      _withClient (package:http/http.dart:164:20)
E/flutter (24259): #5      post (package:http/http.dart:68:5)
E/flutter (24259): #6      AlgoliaIndexReference.facetQuery (package:algolia/src/index_reference.dart:81:31)
E/flutter (24259): #7      ProductController.fetchProducts (package:project/screens/searc_for_all/controller/search_for_all_controller.dart:50:74)
E/flutter (24259): #8      ProductController.onInit (package:project/screens/searc_for_all/controller/search_for_all_controller.dart:21:5)
E/flutter (24259): #9      GetLifeCycleBase._onStart (package:get/get_instance/src/lifecycle.dart:66:5)
E/flutter (24259): #10     InternalFinalCallback.call (package:get/get_instance/src/lifecycle.dart:12:26)
E/flutter (24259): #11     GetInstance._startController (package:get/get_instance/src/get_instance.dart:253:16)
E/flutter (24259): #12     GetInstance._initDependencies (package:get/get_instance/src/get_instance.dart:204:11)
E/flutter (24259): #13     GetInstance.find (package:get/get_instance/src/get_instance.dart:301:17)
E/flutter (24259): #14     GetInstance.put (package:get/get_instance/src/get_instance.dart:86:12)
E/flutter (24259): #15     Inst.put (package:get/get_instance/src/extension_instance.dart:89:21)
E/flutter (24259): #16     new _SearchForAllState (package:project/screens/searc_for_all/searchForAll.dart:37:51)
E/flutter (24259): #17     SearchForAll.createState (package:project/screens/searc_for_all/searchForAll.dart:34:39)
E/flutter (24259): #18     new StatefulElement (package:flutter/src/widgets/framework.dart:4842:25)
E/flutter (24259): #19     StatefulWidget.createElement (package:flutter/src/widgets/framework.dart:770:38)
E/flutter (24259): #20     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3785:40)
E/flutter (24259): #21     Element.updateChild (package:flutter/src/widgets/framework.dart:3540:18)
E/flutter (24259): #22     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6284:14)
E/flutter (24259): #23     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3790:14)
E/flutter (24259): #24     Element.updateChild (package:flutter/src/widgets/framework.dart:3540:18)
E/flutter (24259): #25     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (24259): #26     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (24259): #27     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4735:5)
E/flutter (24259): #28     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4729:5)
E/flutter (24259): #29     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3790:14)
E/flutter (24259): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:3540:18)
E/flutter (24259): #31     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6284:14)
E/flutter (24259): #32     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3790:14)
E/flutter (24259): #33     Element.updateChild (package:flutter/src/widgets/framework.dart:3540:18)
E/flutter (24259): #34     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6284:14)
E/flutter (24259): #35     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3790:14)
E/flutter (24259): #36     Element.updateChild (package:flutter/src/widgets/framework.dart:3540:18)
E/flutter (24259): #37     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
E/flutter (24259): #38     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
E/flutter (24259): #39     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
E/flutter (24259): #40     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4735:5)
E/flutter (24259): #41     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4919:11)
E/flutter (24259): #42     ComponentElement.mount (package:flutter/src/widgets/framework.dart:4729:5)
E/flutter (24259): #43     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3790:14)
E/flutter (24259): #44     Element.updateChild (package:flutter/src/widgets/framework.dart:3540:18)
E/flutter (24259): #45     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6284:14)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source