0

I want to compare one List<MediaItem> with another List<MediaItem>. My MediaItem Class looks like:

class MediaItem
{
String id;
String title;
String description;
Duration duration;
}

Now, How to compare two List<MediaItem> ignoring duration parameter of MediaItem ?

Ranjit Shrestha
  • 622
  • 6
  • 24

1 Answers1

0

You can use method listEquals from flutter/foundation.dart package:

import 'package:flutter/foundation.dart';

final isListAreEquals = listEquals(firstList, secondList);

Also you should implement method equals for your object. See this page for more information about equals method. Variables that are using in equals method are object identity parameters, you need to be careful with it (otherwise you may cause a situation, where some parameter is needed for comparison but it not listed in equals).

fartem
  • 2,361
  • 2
  • 8
  • 20