Check Value In Array Exists Flutter Dart


Answer :

list.contains(x); 

Contains method


Above are the correct answers to the current question. But if someone like me is here to check value inside List of Class object then here is the answer.

class DownloadedFile {  String Url;  String location; } 

List of DownloadedFile

List<DownloadedFile> listOfDownloadedFile = List(); listOfDownloadedFile.add(...); 

Now check if a specific value is inside this list

var contain = listOfDownloadedFile.where((element) => element.Url == "your URL link"); if (contain.isEmpty)    //value not exists else   //value exists 

There maybe better way/approach. If someone know, then let me know. :)


List<int> values = [1, 2, 3, 4]; values.contains(1); // true values.contains(99); // false    

Method - Contains of Iterable does exactly what you need. See the example above.


Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer