Equality of appointment objects

Hello,


When appointment objects are identical, only one is displayed.

You will find attached an example of code (with syncfusion_flutter_calendar: ^19.3.55) and a preview with and without the hashcode and == methods defined.


Have a nice day


Attachment: Sample_8e0afe43.zip

4 Replies

IR Indumathi Ravichandran Syncfusion Team November 24, 2021 10:12 AM UTC

Hi Ilyas, 
 
Thank you for contacting Syncfusion support. 
 
Regarding Query: When appointment objects are identical, only one is displayed. 
 
As per the implementation of the calendar, we are comparing the appointment list for calculating the index value. In this appointment list, get each appointment index always returns 0 because in (==) method only compare event name, from, to values and all the appointments in list are equal event name, from, to values. So, kindly check all properties in the class like the below code snippet. 
 
Code snippet: 
 
@override 
int get hashCode { 
  return Object.hashAll( 
    <Object>[ 
      eventName, 
      from, 
      to,id 
    ], 
  ); 
} 
 
@override 
bool operator ==(Object other) { 
  return other is Meeting && 
      other.eventName == eventName && 
      other.from == from&& 
      other.to == to&&other.id==id; 
} 
 
In default, framework checks all the properties. So that the issue resolved while remove overrides. We hope that this helps you. Please let us know if you need further assistance. 
 
Regards, 
Indumathi R 



IL Ilyas November 24, 2021 11:10 AM UTC

Hello Indumathi,


Thank you for the quick answer and the explanation.


I intentionally omitted the id property, in order to check the content and not the identity.


I don't know what to think about the implementation regarding the comparison.


But I think I will map my Domain objects to a specific object for Calendar that does the comparison on id.


Kind regards,

Ilyas



IR Indumathi Ravichandran Syncfusion Team November 25, 2021 01:21 PM UTC

Hi Ilyas, 
 
Thank you for the update. 
 
Currently we are validating the scenario. We will validate and update you the further details on or before November 29, 2021. We appreciate your patience until then. 
 
Regards, 
Indumathi R 



IR Indumathi Ravichandran Syncfusion Team November 29, 2021 11:36 AM UTC

Hi Ilyas, 
 
Thank you for your patience. 
 
Based on the code snippet, we have checked appointments in the list with each other. In your shared code appointments in the appointment collection are equal. So, it returns the appointment index as 0 for all appointments while calculating the index, when implementing sample with (==) override method. We have checked with the below code snippet. 
 
Code snippet: 
List<Meeting> _getDataSource() { 
  final DateTime begin = DateTime(2022, 01, 20, 12); 
 
  final DateTime end = begin.add(const Duration(hours: 1)); 
 
  final List<Meeting> meetings = <Meeting>[ 
    Meeting( 
      'MO000004', 
      'Conference', 
      begin, 
      end, 
    ), 
    Meeting( 
      'MO000080', 
      'Conference', 
      begin, 
      end, 
    ), 
    Meeting( 
      'MO000084', 
      'Conference', 
      begin, 
      end, 
    ), 
    Meeting( 
      'MO000075', 
      'Conference', 
      begin, 
      end, 
    ), 
    Meeting( 
      'MO000081', 
      'Conference', 
      begin, 
      end, 
    ), 
  ]; 
 
  for (int i = 0; i < meetings.length - 1; i++) { 
    print(meetings[i] == meetings[i + 1]); 
  } 
  return meetings; 
} 
 
 
If possible, can you please share the reason for keeping the same appointment details. It would be helpful for us to analyze and provide you a solution at the earliest. 
 
Regards, 
Indumathi R 


Loader.
Up arrow icon