MotionSpec.fromJson constructor

MotionSpec.fromJson(
  1. Object? json
)

Implementation

factory MotionSpec.fromJson(Object? json) {
  final j = _map(json, 'MotionSpec');
  return MotionSpec(
    verb: _enumByName(PressVerb.values, j['verb'], 'verb'),
    scheme: _enumByName(MotionScheme.values, j['scheme'], 'scheme'),
    pressIn: SpringToken.fromJson(j['pressIn']),
    release: SpringToken.fromJson(j['release']),
    releaseAlt: j['releaseAlt'] == null
        ? null
        : SpringToken.fromJson(j['releaseAlt']),
    depthCdp: _int(j, 'depthCdp'),
    scalePermille: _int(j, 'scalePermille'),
    cornerPermille: _int(j, 'cornerPermille'),
    squishPermille: _int(j, 'squishPermille'),
    stateLayerSnap: _bool(j, 'stateLayerSnap'),
    entry: _enumByName(EntryStyle.values, j['entry'], 'entry'),
    entryScalePermille: _int(j, 'entryScalePermille'),
    entryOffsetCdp: _int(j, 'entryOffsetCdp'),
    entrySpring: j['entrySpring'] == null
        ? null
        : SpringToken.fromJson(j['entrySpring']),
    fx: _enumByName(PressFx.values, j['fx'], 'fx'),
    stepMs: _int(j, 'stepMs'),
    impact: _enumByName(ImpactStyle.values, j['impact'], 'impact'),
    impactPermille: _int(j, 'impactPermille'),
    releaseHaptic: _bool(j, 'releaseHaptic'),
    releaseImpactPermille: _int(j, 'releaseImpactPermille'),
  );
}