spinner_input
spinner_input copied to clipboard
Problem with value update
Hi, @Ali-Azmoud I have the same problem of #1 with version 0.1.2. this is my code:
Future<void> _setCustomHours() async {
return showDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Set hours', textAlign: TextAlign.center,),
content: SingleChildScrollView(
child: ListBody(
mainAxis: Axis.vertical,
children: <Widget>[
Padding(
padding: EdgeInsets.only(
top:15.0
),
),
Center(
child: SpinnerInput(
minValue: 1,
maxValue: 10,
step: 0.5,
fractionDigits: 1,
disabledLongPress: true,
disabledPopup: true,
plusButton: SpinnerButtonStyle(
elevation: 3,
height: 40,
width: 40,
color: Colors.grey[300],
textColor: Colors.black,
borderRadius: BorderRadius.circular(3)
),
minusButton: SpinnerButtonStyle(
elevation: 3,
height: 40,
width: 40,
color: Colors.grey[300],
textColor: Colors.black,
borderRadius: BorderRadius.circular(3)
),
middleNumberWidth: 80,
middleNumberStyle: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold
),
spinnerValue: hours, //hours is a double initialized to 1.0 in the State
onChange: (newValue) {
setState(() => hours = newValue);
},
),
),
],
),
),
actions: <Widget>[
FlatButton(
child: Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
)
],
);
},
);
}
When the app starts, I see the value 1.0. If I tap + or - the value in the state gets updated, while the value I see on the view is still 1.0...
Any idea? Thanks
Hi, sorry for my late response.
If I understand you correctly, you want to update hours
which is inside your main widget context. if this is the case, one way is using Bloc
or ScopedModels
, so that when you update hours
in showDialog
, all related widgets which are displaying hours
, update themselves. I'm not sure if this is related to this package.