Search code examples
flutterflutter-getx

getx RxMap flutter


Could you help me, use package getx, when I use RxMap with the add method it does not let me add to the RxMap, check the getx package, but the add method is not in the rxmap enter image description here

enter image description here


Solution

  • You can simply do like this using RxMap, Instead of add use like this

    final mapObject = RxMap();
    mapObject['test'] = 'item';
    print(mapObject);
    

    Output:

    {test: item}
    

    So, In your case

    void addMapItem(){
    mapItems[DateTime.now().toString()] = DateTime.now().toString();
    }