This repository has been archived on 2023-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
LocalSpend-Tracker/lib/common/widgets/popupListView.dart

52 lines
1.1 KiB
Dart
Raw Normal View History

2019-07-08 14:03:11 +00:00
import 'package:flutter/material.dart';
class PopupListView {
List<String> options = new List<String>();
var context;
String listTitle;
List<SimpleDialogOption> simpleDialogOptions = new List<SimpleDialogOption>();
String result;
PopupListView(context, List<String> options, String title) {
this.context = context;
this.options = options;
this.listTitle = title;
}
List<SimpleDialogOption> getDialogOptions() {
var dialogOptionsList = new List<SimpleDialogOption>();
for (var i = 0; i < options.length; i++) {
dialogOptionsList.add(
new SimpleDialogOption(
// print each iteration to see if any are null
2019-07-08 14:03:11 +00:00
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
2019-07-08 14:03:11 +00:00
}
}