Hi I am having an error while creating an app on Flutter
Error: Method 'toDouble' cannot be called on 'int?' because it is potentially null.
Try calling using ?. instead.
value: SliderValue.toDouble(),
^^^^^^^^
Anyone can help me
Error Screenshots
CodePudding user response:
SliderValue can be null
. you probably have it defined somewhere as
int? SliderValue;
You could change it to
int SliderValue = 0;
to fix it, or alternatively use
value: SliderValue?.toDouble() ?? 0,
to handle the case of when it's null
CodePudding user response:
Add '?' to the SliderValue:
SliderValue?.toDouble()