increment method

void increment()

Implementation

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

  // Automatically cap at the max if specified.

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

  // 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);
  }

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

  // Trigger the callback with debouncing.

  _triggerUpDownCallback();
}