show_scroll_picker.dart
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) 2018, codegrue. All rights reserved. Use of this source code
// is governed by the MIT license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
import '../dialogs/scroll_picker_dialog.dart';
/// Allows selection of a string via a slot machine carousel
void showMaterialScrollPicker({
BuildContext context,
String title,
List<String> items,
String selectedItem,
Color headerColor,
Color headerTextColor,
Color backgroundColor,
Color buttonTextColor,
String confirmText,
String cancelText,
double maxLongSide,
double maxShortSide,
ValueChanged<String> onChanged,
VoidCallback onConfirmed,
VoidCallback onCancelled,
}) {
showDialog<String>(
context: context,
builder: (BuildContext context) {
return ScrollPickerDialog(
items: items,
title: title,
initialItem: selectedItem,
headerColor: headerColor,
headerTextColor: headerTextColor,
backgroundColor: backgroundColor,
buttonTextColor: buttonTextColor,
confirmText: confirmText,
cancelText: cancelText,
maxLongSide: maxLongSide,
maxShortSide: maxLongSide,
);
},
).then((selection) {
if (onChanged != null && selection != null) onChanged(selection);
if (onCancelled != null && selection == null) onCancelled();
if (onConfirmed != null && selection != null) onConfirmed();
});
}