Toggleable toggleable =Toggleable.on;
// ... some logics that changes the toggleablefinal result = toggleable.when(
on: () =>1,
off: () =>2,
);
// You could check the "Usage" section to explore more awesome examples!
It is wrapper for Toggleable which helps using it.
final state =ToggleableState(initialState:Toggleable.off);
state.toggle(); // toggles the state
state.on(); // turn on the state
state.off(); // turn off the state