다음과 같은 목록이 있습니다.
final List _subcoll=[
{'name':'Java','pdfurl':'pdf1','thumbnail':'1'},
{'name':'Dart','pdfurl':'pd2','thumbnail':'2'},
{'name':'JavaScript','pdfurl':'pdf3','thumbnail':'3'},
{'name':'PHP','pdfurl':'pdf4','thumbnail':'4'},
{'name':'Python','pdfurl':'pdf5','thumbnail':'5'},
];
name = java 및 pdffile = pdf1과 같은 단일 값에 어떻게 액세스 할 수 있습니까?`
이에 대한 답을 찾았는지 여부는 모르겠지만 원하는 결과를 얻기 위해 수행하고 싶은 [좀 더 기본적인] 해결책이 있습니다.
기본적으로 배열을 반복하고 다음과 같이 데이터를 가져옵니다. array[index][dictionary_key_name]
Dictionary_key는 {} 데이터에 불과합니다.
// In this case we have keys like 'name', 'pdfurl' and value like 'Java', and 'thumbnail'
// Every key is connected to the value in dictionary or hashmap/hashmap
dictionary = {key: value}
void main(){
final List _subcoll=[
{'name':'Java','pdfurl':'pdf1','thumbnail':'1'},
{'name':'Dart','pdfurl':'pd2','thumbnail':'2'},
{'name':'JavaScript','pdfurl':'pdf3','thumbnail':'3'},
{'name':'PHP','pdfurl':'pdf4','thumbnail':'4'},
{'name':'Python','pdfurl':'pdf5','thumbnail':'5'},
];
/*
You can do whatever in the output you want
My output is to just show you how it is working
Just focus on how I got the result, _subscoll[index][hashkey]
*/
for(int i=0; i<_subcoll.length; i++){
print('name => ${_subcoll[i]['name']}, pdfurl => ${_subcoll[i]['pdfurl']}');
}
}
산출
name => Java, pdfurl => pdf1
name => Dart, pdfurl => pd2
name => JavaScript, pdfurl => pdf3
name => PHP, pdfurl => pdf4
name => Python, pdfurl => pdf5
그 이상을 가지고 놀아보고 결과에 의문이 있으면 알려주십시오.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다