NumberPicker icon indicating copy to clipboard operation
NumberPicker copied to clipboard

NumberPickerDialog

Open sabinabialic opened this issue 3 years ago • 3 comments

In the latest version the NumberPickerDialog is no longer implemented. I'm wondering how to implement this?

sabinabialic avatar Apr 20 '21 14:04 sabinabialic

I have the same problem while use Number Picker Dialog. please hip in

cupid-gracer avatar Apr 22 '21 21:04 cupid-gracer

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

rawquesh avatar Jul 16 '21 04:07 rawquesh

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 openModal() async { await showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: Text('Select Weight', textAlign: TextAlign.center), content: StatefulBuilder(builder: (context, setState) { return Container( height: 350, child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ DecimalNumberPicker( itemCount: 3, minValue: 0, maxValue: 100, decimalPlaces: 1, value: selectedWeight,
onChanged: (value) => setState(() { selectedWeight = value }), ), ElevatedButton( child: Text( 'Approve', ), onPressed: () { Navigator.of(context).pop(); }, ), ], ), ); }), ); }, ) }

potemkini avatar Dec 16 '22 13:12 potemkini