1

enter image description here

I have the x,y for both ends of this line on a canvas, how do I run a gradient from the line sides(as pic).

import 'dart:ui' as ui;
canvas.drawLine(
        Offset(x,
            y),
        Offset(x,
            y),
        Paint()
          ..style = PaintingStyle.stroke
          ..strokeWidth = 4.0
          ..shader = ui.Gradient.linear( // What do I use here? 
          startOffset,
          endOffset,
         [
         color1,
         color2,
         ],
         ),); 
Luke Stanyer
  • 1,404
  • 12
  • 21
  • is any solution find? – Himalay Apr 28 '23 at 10:08
  • I drew lines of different thicknesses on top of each other and colored them to create a gradient that is not as smooth but you can't tell too much. I plan to solve this using this answer: https://stackoverflow.com/questions/73985577/how-do-you-calculate-the-x-y-points-of-all-corners-of-a-square-from-two-only-a-p with a geometry package - will update this if I find the time. – Luke Stanyer May 02 '23 at 10:42

0 Answers0