[FEAT] Dismiss handler for toggle
This commit is contained in:
@@ -87,14 +87,16 @@ class AstromicSwitcherToggleState extends State<AstromicSwitcherToggle> {
|
|||||||
|
|
||||||
//SECTION - Action Callbacks
|
//SECTION - Action Callbacks
|
||||||
Future<void> _onTap(bool newValue) async {
|
Future<void> _onTap(bool newValue) async {
|
||||||
if (widget.onStateChanged != null) {
|
|
||||||
_currentState = await widget.onStateChanged!(_currentState);
|
|
||||||
} else {
|
|
||||||
_currentState = newValue;
|
|
||||||
}
|
|
||||||
setState(() {
|
setState(() {
|
||||||
//
|
_currentState = newValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (widget.onStateChanged != null) {
|
||||||
|
bool shouldRevert = await widget.onStateChanged!(_currentState);
|
||||||
|
setState(() {
|
||||||
|
_currentState = shouldRevert;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//!SECTION
|
//!SECTION
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user