NumberPicker
NumberPicker copied to clipboard
NumberPickerDialog
In the latest version the NumberPickerDialog is no longer implemented. I'm wondering how to implement this?
I have the same problem while use Number Picker Dialog. please hip in
Future<int> showMyNumberPicker() async { return showCupertinoDialog<int>( barrierDismissible: true, context: context, builder: (context) { final borderRadius = BorderRadius.circular(3); final style = ptSans(40); final borderRadius2 = BorderRadius.circular(10); final black26 = Colors.black26; int _currentValue = 1; return StatefulBuilder(builder: (context, setState) { return AlertDialog( content: NumberPicker( minValue: 1, maxValue: 10, value: _currentValue, onChanged: (value) { setState(() { _currentValue = value; }); }, selectedTextStyle: ptSans(68).copyWith(color: themeColor), textStyle: ptSans(50), ), actions: <Widget>[ InkWell( onTap: () => Navigator.of(context).pop(), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 8), child: Text("Cancel", style: style), ), ), InkWell( onTap: () => Navigator.of(context).pop(_currentValue), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 8), child: Text("Ok", style: style), ), ), ], ); }); }, ); }
try this its same as the old one
@sabinabialic @cupid-gracer
You can create your custom dialog as below. You can update the selection by onChanged method under DecimalNumberPicker() but even so I've added an elavated button in order to close the custom dialog.
bool selectedWeight = 0.0
Future
onChanged: (value) => setState(() {
selectedWeight = value
}),
),
ElevatedButton(
child: Text(
'Approve',
),
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
);
}),
);
},
)
}