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
Asked
Active
Viewed 3,510 times
0

Barbora
- 921
- 1
- 6
- 11

jose gonzalez
- 3
- 1
- 3
2 Answers
4
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();
}

Mohan Sai Manthri
- 2,808
- 1
- 11
- 26
0
i found this use full to declare it as literal
class FooController extends GetxController {
final data = <String, dynamic>{}.obs;
}

Saf Rahman
- 11
- 1
-
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 22 '23 at 18:16