init method

  1. @protected
void init()

Implementation

@protected
void init() {
  if (widget.settingsKey == null) {
    return;
  }

  this.prefs = prefs;
  Object? currentValue = prefs.get(widget.settingsKey!);

  if (!(T == String) && (currentValue is String)) {
    currentValue = deserialize(currentValue);
  }

  setState(() {
    if (currentValue != null && !(currentValue is T?)) {
      value = widget.defaultValue;
    }
    if (currentValue == null) {
      currentValue = widget.defaultValue;
    }
    value = currentValue as T?;
  });
}