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
Felix a3a52ebe4a Submit Receipt fixed
'find' works, recurring options work, only thing that needs doing is adding organisation's address to api request
2019-07-15 14:48:41 +01:00

36 lines
No EOL
936 B
Dart

import 'package:flutter/material.dart';
import 'dart:async';
class PopupListView {
Future<dynamic> dialog(context, List<String> options, String title) {
return showDialog<dynamic>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return SimpleDialog(
title: Text(title),
children: getDialogOptions(context, options),
);
},
);
}
List<Widget> getDialogOptions(context, List<String> options /*, Function onPressed*/) {
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
child: Text(options[i]),
onPressed: () {
Navigator.of(context).pop(options[i]);
},
),
);
}
return dialogOptionsList;
}
}