@@ -2296,25 +2296,44 @@ class Gradient extends Shader {
22962296 /// If `matrix4` is provided, the gradient fill will be transformed by the
22972297 /// specified 4x4 matrix relative to the local coordinate system. `matrix4` must
22982298 /// be a column-major matrix packed into a list of 16 values.
2299+ ///
2300+ /// If `focal` is provided and not equal to `center` or `focalRadius` is
2301+ /// provided and not equal to 0.0, the generated shader will be a two point
2302+ /// conical radial gradient, with `focal` being the center of the focal
2303+ /// circle and `focalRadius` being the radius of that circle. If `focal` is
2304+ /// provided and not equal to `center` , at least one of the two offsets must
2305+ /// not be equal to [Offset.zero] .
22992306 Gradient .radial (
23002307 Offset center,
23012308 double radius,
23022309 List <Color > colors, [
23032310 List <double > colorStops,
23042311 TileMode tileMode = TileMode .clamp,
2305- Float64List matrix4
2312+ Float64List matrix4,
2313+ Offset focal,
2314+ double focalRadius
23062315 ]) : assert (_offsetIsValid (center)),
23072316 assert (colors != null ),
23082317 assert (tileMode != null ),
23092318 assert (matrix4 == null || _matrix4IsValid (matrix4)),
23102319 super ._() {
2320+ focal ?? = center;
2321+ focalRadius ?? = 0.0 ;
23112322 _validateColorStops (colors, colorStops);
23122323 final Int32List colorsBuffer = _encodeColorList (colors);
23132324 final Float32List colorStopsBuffer = colorStops == null ? null : new Float32List .fromList (colorStops);
2314- _constructor ();
2315- _initRadial (center.dx, center.dy, radius, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
2325+
2326+ if (center == focal && focalRadius != 0.0 ) {
2327+ _constructor ();
2328+ _initRadial (center.dx, center.dy, radius, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
2329+ } else {
2330+ assert (center != Offset .zero || focal != Offset .zero); // will result in nullptr in Skia side
2331+ _constructor ();
2332+ _initConical (focal.dx, focal.dy, focalRadius, center.dx, center.dy, radius, colorsBuffer, colorStopsBuffer, tileMode.index, matrix4);
2333+ }
23162334 }
23172335 void _initRadial (double centerX, double centerY, double radius, Int32List colors, Float32List colorStops, int tileMode, Float64List matrix4) native 'Gradient_initRadial' ;
2336+ void _initConical (double startX, double startY, double startRadius, double endX, double endY, double endRadius, Int32List colors, Float32List colorStops, int tileMode, Float64List matrix4) native 'Gradient_initTwoPointConical' ;
23182337
23192338 /// Creates a sweep gradient centered at `center` that starts at `startAngle`
23202339 /// and ends at `endAngle` .
0 commit comments