toggle method

void toggle(
  1. BuildContext context, {
  2. bool forceLock = false,
})

Implementation

void toggle(BuildContext context, {bool forceLock = false}) {
  context.guardoActionWithResult(
    onSuccess: () async {
      state = !state;
      await JetStorage.write(_key, state);
      if (forceLock) {
        if (context.mounted) {
          context.lockApp();
        }
      }
    },
    onFailure: (e) {
      context.showToast(e.toString());
    },
  );
}