lerp<T> static method

Linearly interpolate between two FlutterFolderViewThemes

Implementation

static FlutterFolderViewTheme<T> lerp<T>(
  FlutterFolderViewTheme<T>? a,
  FlutterFolderViewTheme<T>? b,
  double t,
) {
  if (a == null && b == null) {
    return FlutterFolderViewTheme<T>.light();
  }
  if (a == null) return b!;
  if (b == null) return a;

  return FlutterFolderViewTheme<T>(
    lineTheme: FolderViewLineTheme.lerp(a.lineTheme, b.lineTheme, t),
    scrollbarTheme: FolderViewScrollbarTheme.lerp(
      a.scrollbarTheme,
      b.scrollbarTheme,
      t,
    ),
    folderTheme: FolderNodeTheme.lerp(a.folderTheme, b.folderTheme, t),
    parentTheme: ParentNodeTheme.lerp(a.parentTheme, b.parentTheme, t),
    childTheme: ChildNodeTheme.lerp(a.childTheme, b.childTheme, t),
    expandIconTheme:
        ExpandIconTheme.lerp(a.expandIconTheme, b.expandIconTheme, t),
    spacingTheme: FolderViewSpacingTheme.lerp(
      a.spacingTheme,
      b.spacingTheme,
      t,
    ),
    nodeStyleTheme: FolderViewNodeStyleTheme.lerp(
      a.nodeStyleTheme,
      b.nodeStyleTheme,
      t,
    ),
    animationDuration: t < 0.5 ? a.animationDuration : b.animationDuration,
    rowHeight: t < 0.5 ? a.rowHeight : b.rowHeight,
    rowSpacing: t < 0.5 ? a.rowSpacing : b.rowSpacing,
  );
}