1

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}

1

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.