'How to Call Dynamic Variable on Flutter
I have the following code
List toCheck = ['province','regency','district','village'];
List data = [];
toCheck.forEach((value) {
//sample data would looke like (object.province)
if(object.value!=null){ => need to call with object.value
data.add(value);
}
});
If it is in php, that would be look like ${$value}
Solution 1:[1]
Try this:
ElevatedButton(onPressed: (){
List toCheck = ['province','regency','district','village'];
List data = [];
toCheck.forEach((value) {
//sample data would looke like (object.province)
if(value!=null){
data.add(value);
}
});
If I understand what you want correctly, this should check if the values of your list are not null, and if so, it will add each value to the data
list.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Abdallah Ibrahim |