Flutter: Convert Map to Json


I am trying to convert a complex map to Json String to pass to my Firebase Realtime Database.

The Map:

_data = {
          'description':'This is my description',
          'price': '700'

What I tried:


This gives me an error:

Converting object to an encodable object failed


I got the mistake! I was also using a for loop for putting the data in the map. However while using json.encode(for loop) doesn’t work somehow. I removed it and now it does.

Answered By – Ali Solanki

Answer Checked By – Gilberto Lyons (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *