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

37 lines
942 B
Dart
Raw Permalink Normal View History

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