checkRow static method

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

Implementation

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