lerp method

  1. @override
NodeFlowTheme lerp(
  1. covariant NodeFlowTheme? other,
  2. double t
)
override

Linearly interpolate with another ThemeExtension object.

The t argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning a (or something equivalent to a), 1.0 meaning that the interpolation has finished, returning b (or something equivalent to b), and values in between meaning that the interpolation is at the relevant point on the timeline between a and b. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves such as Curves.elasticInOut).

Values for t are usually obtained from an Animation<double>, such as an AnimationController.

Implementation

@override
NodeFlowTheme lerp(NodeFlowTheme? other, double t) {
  if (other is! NodeFlowTheme) return this;

  return NodeFlowTheme(
    nodeTheme: nodeTheme,
    // NodeTheme doesn't support lerp
    connectionTheme: connectionTheme,
    // ConnectionTheme doesn't support lerp
    temporaryConnectionTheme: temporaryConnectionTheme,
    // ConnectionTheme doesn't support lerp
    connectionAnimationDuration: t < 0.5
        ? connectionAnimationDuration
        : other.connectionAnimationDuration,
    portTheme: portTheme,
    // PortTheme doesn't support lerp
    labelTheme: t < 0.5 ? labelTheme : other.labelTheme,
    backgroundColor:
        Color.lerp(backgroundColor, other.backgroundColor, t) ??
        backgroundColor,
    gridColor: Color.lerp(gridColor, other.gridColor, t) ?? gridColor,
    gridSize: lerpDouble(gridSize, other.gridSize, t) ?? gridSize,
    gridThickness:
        lerpDouble(gridThickness, other.gridThickness, t) ?? gridThickness,
    gridStyle: t < 0.5 ? gridStyle : other.gridStyle,
    selectionColor:
        Color.lerp(selectionColor, other.selectionColor, t) ?? selectionColor,
    selectionBorderColor:
        Color.lerp(selectionBorderColor, other.selectionBorderColor, t) ??
        selectionBorderColor,
    selectionBorderWidth:
        lerpDouble(selectionBorderWidth, other.selectionBorderWidth, t) ??
        selectionBorderWidth,
    cursorStyle: t < 0.5 ? cursorStyle : other.cursorStyle,
    dragCursorStyle: t < 0.5 ? dragCursorStyle : other.dragCursorStyle,
    nodeCursorStyle: t < 0.5 ? nodeCursorStyle : other.nodeCursorStyle,
    portCursorStyle: t < 0.5 ? portCursorStyle : other.portCursorStyle,
    debugMode: t < 0.5 ? debugMode : other.debugMode,
  );
}