animationTrigger method

  1. @preferInline
AnimationTrigger animationTrigger({
  1. String key = FlutterPropertyKeys.trigger,
  2. AnimationTrigger defaultValue = AnimationTrigger.onEnter,
  3. Object? target,
  4. bool warmUp = false,
})

Retrieves an AnimationTrigger value from the JSON map for the given key.

Looks up the value associated with key in the JSON. If the value is already an AnimationTrigger, it is returned as is. If the value is a String or int, it is converted using the lookup tables. Otherwise, it returns defaultValue.

  • key: The key to look up in the JSON map. Defaults to 'trigger'.
  • defaultValue: The value to return if the key is not found or cannot be resolved. Defaults to AnimationTrigger.onEnter.

Returns:

  • An AnimationTrigger if the value is valid or can be parsed.
  • defaultValue if the value is not a valid AnimationTrigger or cannot be parsed.

Implementation

@preferInline
AnimationTrigger animationTrigger({
  String key = FlutterPropertyKeys.trigger,
  AnimationTrigger defaultValue = AnimationTrigger.onEnter,
  Object? target,
  bool warmUp = false,
}) {
  final value = _readProp(key, target, warmUp);

  if (value is AnimationTrigger) return value;

  if (value == null) return defaultValue;

  switch (value) {
    case String():
      if (envAttributeWarmUpEnabled) {
        if (warmUp) {
          return _animationTriggerStringLookupTable[value]!;
        } else {
          return _json[key] = _animationTriggerStringLookupTable[value]!;
        }
      } else {
        return _json[key] = _animationTriggerStringLookupTable[value]!;
      }
    case int():
      if (envAttributeWarmUpEnabled) {
        if (warmUp) {
          return _animationTriggerIntLookupTable[value]!;
        } else {
          return _json[key] = _animationTriggerIntLookupTable[value]!;
        }
      } else {
        return _json[key] = _animationTriggerIntLookupTable[value]!;
      }
    default:
      return defaultValue;
  }
}