showMaterialNumberPicker function
Future<int?>
showMaterialNumberPicker({
- required BuildContext context,
- String? title,
- required int minNumber,
- required int maxNumber,
- int? selectedNumber,
- int step = 1,
- Color? headerColor,
- TextStyle? headerTextStyle,
- Color? backgroundColor,
- Color? bottomBorderColor,
- TextStyle? confirmTextStyle,
- TextStyle? cancelTextStyle,
- TextStyle? scrollItemTextStyle,
- TextStyle? selectedItemTextStyle,
- String? confirmText,
- String? cancelText,
- double? maxLongSide,
- double? maxShortSide,
- ValueChanged<
int> ? onChanged, - VoidCallback? onConfirmed,
- VoidCallback? onCancelled,
Implementation
Future<int?> showMaterialNumberPicker({
required BuildContext context,
String? title,
required final int minNumber,
required final int maxNumber,
final int? selectedNumber,
final int step = 1,
Color? headerColor,
TextStyle? headerTextStyle,
Color? backgroundColor,
Color? bottomBorderColor,
TextStyle? confirmTextStyle,
TextStyle? cancelTextStyle,
TextStyle? scrollItemTextStyle,
TextStyle? selectedItemTextStyle,
String? confirmText,
String? cancelText,
double? maxLongSide,
double? maxShortSide,
ValueChanged<int>? onChanged,
VoidCallback? onConfirmed,
VoidCallback? onCancelled,
}) {
List<int> items = [];
for (int i = minNumber; i <= maxNumber; i += step) {
items.add(i);
}
return showDialog<int>(
context: context,
builder: (BuildContext context) {
return ScrollPickerDialog<int>(
items: items,
title: title,
selectedItem: selectedNumber,
headerColor: headerColor,
backgroundColor: backgroundColor,
bottomBorderColor: bottomBorderColor,
headerTextStyle: headerTextStyle,
confirmTextStyle: confirmTextStyle,
scrollItemTextStyle: scrollItemTextStyle,
selectedItemTextStyle: selectedItemTextStyle,
cancelTextStyle: cancelTextStyle,
confirmText: confirmText,
cancelText: cancelText,
maxLongSide: maxLongSide,
maxShortSide: maxLongSide,
);
},
).then((selection) {
if (selection != null) {
onChanged?.call(selection);
onConfirmed?.call();
} else {
onCancelled?.call();
}
return selection;
});
}