decrement method

void decrement()

Implementation

void decrement() async {
  num currentValue = num.tryParse(widget.controller.text) ?? 0;
  currentValue -= widget.interval;

  // Automatically floor at min if specified.

  if (widget.min != null) {
    currentValue = max(currentValue, widget.min!);
  }

  // Round to the specified decimal places if needed.

  if (widget.decimalPlaces > 0) {
    currentValue = double.parse(
      currentValue.toStringAsFixed(widget.decimalPlaces),
    );
  }

  ref.read(widget.stateProvider.notifier).state = currentValue;

  // Save to SharedPreferences if key is provided.

  if (widget.sharedPrefsKey != null) {
    await _saveToSharedPrefs(currentValue);
  }

  // Legacy code for backward compatibility.

  if (widget.label == 'Seed:') {
    final prefs = await SharedPreferences.getInstance();
    prefs.setInt('randomSeed', currentValue.toInt());
  }

  // Trigger the callback with debouncing.

  _triggerUpDownCallback();
}