import 'package:flutter/material.dart'; class PopupListView { List options = new List(); var context; String listTitle; List simpleDialogOptions = new List(); String result; PopupListView(context, List options, String title) { this.context = context; this.options = options; this.listTitle = title; } List getDialogOptions() { var dialogOptionsList = new List(); for (var i = 0; i < options.length; i++) { dialogOptionsList.add( new SimpleDialogOption( // print each iteration to see if any are null child: Text(options[i]), onPressed: () { Navigator.of(this.context).pop(); // print("Chosen organisation is " + options[i]); optionChosen(options[i]); }, ), ); } return dialogOptionsList; } Widget dialog() { return new SimpleDialog( title: Text(listTitle), children : getDialogOptions(), ); } void optionChosen(String option) { // now pass `option` to } }