fromMap static method

PullToRefreshSettings? fromMap(
  1. Map<String, dynamic>? map, {
  2. EnumMethod? enumMethod,
})

Gets a possible PullToRefreshSettings instance from a Map value.

Implementation

static PullToRefreshSettings? fromMap(
  Map<String, dynamic>? map, {
  EnumMethod? enumMethod,
}) {
  if (map == null) {
    return null;
  }
  final instance = PullToRefreshSettings(
    attributedTitle: AttributedString.fromMap(
      map['attributedTitle']?.cast<String, dynamic>(),
      enumMethod: enumMethod,
    ),
    backgroundColor: map['backgroundColor'] != null
        ? UtilColor.fromStringRepresentation(map['backgroundColor'])
        : null,
    color: map['color'] != null
        ? UtilColor.fromStringRepresentation(map['color'])
        : null,
    distanceToTriggerSync: map['distanceToTriggerSync'],
    size: switch (enumMethod ?? EnumMethod.nativeValue) {
      EnumMethod.nativeValue => PullToRefreshSize.fromNativeValue(
        map['size'],
      ),
      EnumMethod.value => PullToRefreshSize.fromValue(map['size']),
      EnumMethod.name => PullToRefreshSize.byName(map['size']),
    },
    slingshotDistance: map['slingshotDistance'],
  );
  instance.allowWithNoScrollbar = map['allowWithNoScrollbar'];
  instance.enabled = map['enabled'];
  return instance;
}