editDialog method

Future<void> editDialog()

Implementation

Future<void> editDialog() async {
  int? result;

  if (pref.format == Pref.FORMAT_INT_SLIDER &&
      context != null &&
      pref.min != null &&
      pref.max != null &&
      pref.min! <= pref.max!) {
    result = await showDialog(
      context: context!,
      builder: (BuildContext context) => PrefSliderEdit(
        pref: pref,
      ),
    );
  } else if (context != null) {
    String? numStr = await showDialog(
      context: context!,
      builder: (BuildContext context) => PrefTextEdit(
        pref: pref,
      ),
    );
    if (numStr != null) {
      result = int.parse(numStr);
    }
  }

  if (result != null) {
    if (callback != null) {
      pref.value = result;
      callback!(pref);
    }
  }
}