content: import 'package:cloud_firestore/cloud_firestore.dart';
  
  class CategoryModel {
    String id;
    String name;
    String image;
    String parentId;
    bool isFeatured;
  
    CategoryModel({
      required this.id,
      required this.image,
      required this.name,
      required this.isFeatured,
      this.parentId = '',
    });
  
    ///Empty helper function
    static CategoryModel empty() =>
        CategoryModel(id: '', image: '', name: '', isFeatured: false);
  
    ///convert model to json structure so that i can store model in firebase
    Map<String, dynamic> toJson() {
      return {
        'Name': name,
        'Image': image,
        'ParentId': parentId,
        'IsFeatured': isFeatured,
      };
    }
  
    ///map json oriented document snapshot from firebase to user model
    factory CategoryModel.fromSnapshot(
        DocumentSnapshot<Map<String, dynamic>> document) {
      if (document.data() != null) {
        final data = document.data()!;
  
        //Map JSON record to the model
        return CategoryModel(
            id: document.id,
            image: data['Image'] ?? '',
            name: data['Name'] ?? '',
            isFeatured: data['IsFeatured'] ?? false,
        );
      } else {
        return CategoryModel.empty();
      }
    }
  }