shader method Null safety

Shader shader(
  1. {Vector4? uColor,
  2. double? uAlpha,
  3. Vector4? uSparkleColor,
  4. double? uSparkleAlpha,
  5. double? uBlur,
  6. Vector2? uCenter,
  7. double? uRadiusScale,
  8. double? uMaxRadius,
  9. Vector2? uResolutionScale,
  10. Vector2? uNoiseScale,
  11. double? uNoisePhase,
  12. double? uTurbulencePhase,
  13. Vector2? uCircle1,
  14. Vector2? uCircle2,
  15. Vector2? uCircle3,
  16. Vector2? uRotation1,
  17. Vector2? uRotation2,
  18. Vector2? uRotation3}
)

Creates a shader with the original program and optional uniforms.

A new shader must be made whenever the uniforms are updated.

Implementation

Shader shader({
  Vector4? uColor,
  double? uAlpha,
  Vector4? uSparkleColor,
  double? uSparkleAlpha,
  double? uBlur,
  Vector2? uCenter,
  double? uRadiusScale,
  double? uMaxRadius,
  Vector2? uResolutionScale,
  Vector2? uNoiseScale,
  double? uNoisePhase,
  double? uTurbulencePhase,
  Vector2? uCircle1,
  Vector2? uCircle2,
  Vector2? uCircle3,
  Vector2? uRotation1,
  Vector2? uRotation2,
  Vector2? uRotation3,
}) {
  return _program.shader(
    floatUniforms: Float32List.fromList(<double>[
      ...uColor != null ? uColor.storage : <double>[0, 0, 0, 0],
      ...uAlpha != null ? <double>[uAlpha] : <double>[0],
      ...uSparkleColor != null ? uSparkleColor.storage : <double>[0, 0, 0, 0],
      ...uSparkleAlpha != null ? <double>[uSparkleAlpha] : <double>[0],
      ...uBlur != null ? <double>[uBlur] : <double>[0],
      ...uCenter != null ? uCenter.storage : <double>[0, 0],
      ...uRadiusScale != null ? <double>[uRadiusScale] : <double>[0],
      ...uMaxRadius != null ? <double>[uMaxRadius] : <double>[0],
      ...uResolutionScale != null ? uResolutionScale.storage : <double>[0, 0],
      ...uNoiseScale != null ? uNoiseScale.storage : <double>[0, 0],
      ...uNoisePhase != null ? <double>[uNoisePhase] : <double>[0],
      ...uCircle1 != null ? uCircle1.storage : <double>[0, 0],
      ...uCircle2 != null ? uCircle2.storage : <double>[0, 0],
      ...uCircle3 != null ? uCircle3.storage : <double>[0, 0],
      ...uRotation1 != null ? uRotation1.storage : <double>[0, 0],
      ...uRotation2 != null ? uRotation2.storage : <double>[0, 0],
      ...uRotation3 != null ? uRotation3.storage : <double>[0, 0],
    ]),
  );
}