checkRow static method

Row checkRow(
  1. ZugClient client,
  2. String caption,
  3. String prop,
  4. bool defaultValue,
  5. Function onChange, {
  6. Function? onTrue,
  7. Function? onFalse,
})

Implementation

static Row checkRow(ZugClient client, String caption, String prop, bool defaultValue, Function onChange, {Function? onTrue, Function? onFalse}) {
  return Row(
    mainAxisAlignment: MainAxisAlignment.center,
    children: [
      Text("$caption:"),
      Checkbox(
          value: client.prefs?.getBool(prop) ?? defaultValue,
          onChanged: (b) {
            client.prefs?.setBool(prop, b ?? defaultValue).then((value) {
              ZugClient.log.info("Setting $caption: $b");
              onChange();
            });
            if ((b ?? false)) {
              if (onTrue != null) onTrue();
            } else {
              if (onFalse != null) { //ZugClient.log.info(onFalse.toString());
                onFalse();
              }
            }
          }),
    ],
  );
}