Map<String, dynamic> objectToMap(Object dartObject) { // Serialize the Dart object to JSON string, then decode it into a map return jsonDecode(jsonEncode(dartObject)) as Map<String, dynamic>; }