[FEAT] Dismiss handler for toggle

This commit is contained in:
2026-01-25 14:05:29 +02:00
parent 5690525bd0
commit 0f19d432c7
2 changed files with 9 additions and 8 deletions

View File

@@ -32,7 +32,7 @@ class AstromicSwitcherToggle extends StatefulWidget {
/// If provided, you have to change the variable yourself in the onStateChanged!
final bool? stateVariable;
final bool? initialState;
final bool Function(bool)? onStateChanged;
final Future<bool> Function(bool)? onStateChanged;
//s1 -- Configuration
final AstromicToggleConfiguration? configuration;
//s1 -- Style
@@ -86,13 +86,14 @@ class AstromicSwitcherToggleState extends State<AstromicSwitcherToggle> {
}
//SECTION - Action Callbacks
_onTap(bool newValue) {
setState(() {
_onTap(bool newValue) async {
if (widget.onStateChanged != null) {
_currentState = widget.onStateChanged!(_currentState);
_currentState = await widget.onStateChanged!(_currentState);
} else {
_currentState = newValue;
}
setState(() {
//
});
}
//!SECTION

View File

@@ -42,7 +42,7 @@ class AstromicToggles {
static Widget switcher({
bool? stateVariable,
bool? initialState,
bool Function(bool)? onStateChanged,
Future<bool> Function(bool)? onStateChanged,
AstromicToggleConfiguration? configuration,
AstromicSwitcherToggleStyle Function(bool isEnabled, bool isSelected)? style,
Widget Function(bool isEnabled, bool isSelected)? label,