Вы можете скопировать полный код вставки и запустить ниже
Шаг 1: import 'dart:ui' as ui;
Шаг 2: Удалите from: to: colors: colorStops:
рабочая демоверсия
полный код
import 'dart:math';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
class X1Painter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final tracePaint = Paint()
..strokeJoin = StrokeJoin.round
..strokeWidth = 2.0
..color = Colors.blue
..style = PaintingStyle.stroke;
// create a bounding square, based on the centre and radius of the arc
Rect rect = new Rect.fromCircle(
center: new Offset(165.0, 55.0),
radius: 180.0,
);
tracePaint.shader = ui.Gradient.linear(
Offset(0, 0),
Offset(200, 200),
<Color>[
Colors.green.withOpacity(1.0),
Colors.green.withOpacity(0.3),
Colors.yellow.withOpacity(0.2),
Colors.red.withOpacity(0.1),
Colors.red.withOpacity(0.0),
],
[
0.0,
0.5,
0.7,
0.9,
1.0,
],
);
// and draw an arc
canvas.drawArc(rect, pi / 4, pi * 3 / 4, true, tracePaint);
}
@override
bool shouldRepaint(X1Painter oldDelegate) {
return true;
}
}
class X1Demo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(title: const Text('Arcs etc')),
body: new CustomPaint(
painter: new X1Painter(),
),
);
}
}
void main() {
runApp(
new MaterialApp(
theme: new ThemeData.dark(),
home: new X1Demo(),
),
);
}