4
How to search in an array of strings using complete and incomplete orders, similar to what the phonebook does.
Example:
List array1 = ['Escola','Estadual','José','da','silva'];
Lista busca = ['José','Silva','Estad'];
I want Uca to contain in array1, doing research for complete and incomplete words.
I tried it this way:
void main() {
List storeName = ['ESCOLA','ESTADUAL','SAO','JOAO'];
List queryList = ['ESCOLA','SAO', 'JOAO'];
List vazia = [];
for(var i = 0; i< storeName.length;i++){
for(var x = 0; x< queryList.length;x++){
if(storeName[i].contains(queryList[x])){
if(vazia.indexOf(storeName[i]) == -1){
vazia.add(storeName[i]);
}else{
print('n tem');
}
}
}
}
print(vazia);
}
But what I really want is if I do:
List array1 = ['Escola','Estadual','José','da','silva'];
Lista busca = ['José','Silva','Esta'];
busca in array1 = true
And if you search like this, be false:
List array1 = ['Escola','Estadual','José','da','silva'];
Lista busca = ['José','Silva','Estlp'];
busca in array1 = false
Another interesting example is:
.contains("Dart is nice", "nice Dart")); //true
.contains("Dart is nice", "nice Darte")); //false
.contains("Dart is nice", "is Dar")); //true
Edit your question and let us know what you have tried so far, so we can help you better.
– Matheus Ribeiro
It is important that you show the effort you have already made in your research and attempts. Putting an example code that is almost working is a way to help you solve your problem more punctually. When you put in the standards for the question to accept answers again I put one of the possible solutions to your case. If you have the example I use even your example and only adjust with what you need.
– Leonardo Paim