The argument type 'Object?' can't be assigned to the parameter type 'Map<dynamic, dynamic>'. GetX


so basically i’m frustrated by this ‘Object?’ type, i already tried t change its type in core file but i was worried to cause a weird behavior in the future. heres my code any kind of help will be appreciated

class HomeViewModel extends GetxController{

List<CategoryModel> get categorymodel => _categorymodel;
late DocumentSnapshot doc;

List<CategoryModel> _categorymodel = [];

final CollectionReference _categoryCollectionRef = 


_categoryCollectionRef.get().then((value) {
  for(int i = 0; i<;i++){


and this one is from my model class:

class CategoryModel {
late String name, image;

CategoryModel({required, required this.image});

CategoryModel.fromJson(Map<dynamic, dynamic> map) {
if (map == null) {
name = map['name'];
image = map['image'];

toJson() {
return {
  'name': name,
  'image': image,


You need to specify the type of data you’re expecting from the DocumentSnapshot.

Change this line:


to this:

  _categorymodel.add(CategoryModel.fromJson([i].data() as Map<String, dynamic>));

Check out the guide for migration to cloud_firestore 2.0.0.

Answered By – Victor Eronmosele

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.