-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to update the value programatically #17
Comments
Hi, im really sorry for the late response :( In case you still want to continue with this case, what value do you mean exactly? thank you for your interest in the project |
I got a similar question. LiteRollingSwitch(
//initial value
value: bSubscribe,
width: ScreenUtil().setWidth(250),
textOn: t.ON,
textOff: t.OFF,
colorOn: AppColors.themeBlue,
colorOff: AppColors.darkGrey,
iconOn: Icons.notifications,
iconOff: Icons.notifications_off,
textSize: ScreenUtil().setSp(40),
textOnColor: Colors.white,
onChanged: (bool state) {
_subscriptionAPI(!bSubscribe);
},
onTap: () {},
onDoubleTap: () {},
onSwipe: () {},
) if (response.statusCode == 200) {
await prefs.setBool(widget.currentDeviceName, doSubscribe);
setState(() {
bSubscribe = doSubscribe;
});
} Also, I wonder if I should add _subscriptionAPI(!bSubscribe) to all events or just onChanged is enough. |
Hi @hulan0523, I highly recommend using the state value that you are receiving through the component callback onChanged, as this is the current value that you want to change. This way, you can ensure that your code sends the 'real' value of the component state to be updated (i.e., the value that should be sent to your API). Additionally, it is considered best practice to receive the new state directly from the API once the value has been updated, if this is an approachable option from your API's response. LiteRollingSwitch(
//initial value
value: bSubscribe,
width: ScreenUtil().setWidth(250),
textOn: t.ON,
textOff: t.OFF,
colorOn: AppColors.themeBlue,
colorOff: AppColors.darkGrey,
iconOn: Icons.notifications,
iconOff: Icons.notifications_off,
textSize: ScreenUtil().setSp(40),
textOnColor: Colors.white,
onChanged: (bool state) {
_subscriptionAPI(state);
},
onTap: () {},
onDoubleTap: () {},
onSwipe: () {},
) I hope this could be of help Cheers! |
How to update the value with Realtime Firebase |
in case on switch tap i want to confirmation and according to dialog input if yes then only i want to change the value of switch for this type case this switch is not usefull. in future you can update this to update value programaticaly. |
HI,
Can you please suggest how to update the value programatically.
The text was updated successfully, but these errors were encountered: