1.0.0
This commit is contained in:
@@ -0,0 +1,513 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:fl_chart_app/presentation/resources/app_resources.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ScatterChartSample1 extends StatefulWidget {
|
||||
ScatterChartSample1({super.key});
|
||||
|
||||
final blue1 = AppColors.contentColorBlue.withValues(alpha: 0.5);
|
||||
final blue2 = AppColors.contentColorBlue;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => ScatterChartSample1State();
|
||||
}
|
||||
|
||||
class ScatterChartSample1State extends State<ScatterChartSample1> {
|
||||
final maxX = 50.0;
|
||||
final maxY = 50.0;
|
||||
final radius = 8.0;
|
||||
|
||||
bool showFlutter = true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
showFlutter = !showFlutter;
|
||||
});
|
||||
},
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: ScatterChart(
|
||||
ScatterChartData(
|
||||
scatterSpots: showFlutter ? flutterLogoData() : randomData(),
|
||||
minX: 0,
|
||||
maxX: maxX,
|
||||
minY: 0,
|
||||
maxY: maxY,
|
||||
borderData: FlBorderData(
|
||||
show: false,
|
||||
),
|
||||
gridData: const FlGridData(
|
||||
show: false,
|
||||
),
|
||||
titlesData: const FlTitlesData(
|
||||
show: false,
|
||||
),
|
||||
scatterTouchData: ScatterTouchData(
|
||||
enabled: false,
|
||||
),
|
||||
),
|
||||
duration: const Duration(milliseconds: 600),
|
||||
curve: Curves.fastOutSlowIn,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<ScatterSpot> flutterLogoData() {
|
||||
return [
|
||||
/// section 1
|
||||
ScatterSpot(
|
||||
20,
|
||||
14.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
20,
|
||||
14.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
22,
|
||||
16.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
24,
|
||||
18.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
22,
|
||||
12.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
24,
|
||||
14.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
26,
|
||||
16.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
24,
|
||||
10.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
26,
|
||||
12.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
28,
|
||||
14.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
26,
|
||||
8.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
28,
|
||||
10.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
30,
|
||||
12.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
28,
|
||||
6.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
30,
|
||||
8.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
32,
|
||||
10.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
30,
|
||||
4.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
32,
|
||||
6.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
34,
|
||||
8.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
34,
|
||||
4.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
36,
|
||||
6.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
38,
|
||||
4.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue1, radius: radius),
|
||||
),
|
||||
|
||||
/// section 2
|
||||
ScatterSpot(
|
||||
20,
|
||||
14.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
22,
|
||||
12.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
24,
|
||||
10.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
22,
|
||||
16.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
24,
|
||||
14.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
26,
|
||||
12.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
24,
|
||||
18.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
26,
|
||||
16.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
28,
|
||||
14.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
26,
|
||||
20.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
28,
|
||||
18.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
30,
|
||||
16.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
28,
|
||||
22.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
30,
|
||||
20.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
32,
|
||||
18.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
30,
|
||||
24.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
32,
|
||||
22.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
34,
|
||||
20.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
34,
|
||||
24.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
36,
|
||||
22.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
38,
|
||||
24.5,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
/// section 3
|
||||
ScatterSpot(
|
||||
10,
|
||||
25,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
12,
|
||||
23,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
14,
|
||||
21,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
12,
|
||||
27,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
14,
|
||||
25,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
16,
|
||||
23,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
14,
|
||||
29,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
16,
|
||||
27,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
18,
|
||||
25,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
16,
|
||||
31,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
18,
|
||||
29,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
20,
|
||||
27,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
18,
|
||||
33,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
20,
|
||||
31,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
22,
|
||||
29,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
20,
|
||||
35,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
22,
|
||||
33,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
24,
|
||||
31,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
22,
|
||||
37,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
24,
|
||||
35,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
26,
|
||||
33,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
24,
|
||||
39,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
26,
|
||||
37,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
28,
|
||||
35,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
26,
|
||||
41,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
28,
|
||||
39,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
30,
|
||||
37,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
28,
|
||||
43,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
30,
|
||||
41,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
32,
|
||||
39,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
30,
|
||||
45,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
32,
|
||||
43,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
34,
|
||||
41,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
34,
|
||||
45,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
ScatterSpot(
|
||||
36,
|
||||
43,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
|
||||
ScatterSpot(
|
||||
38,
|
||||
45,
|
||||
dotPainter: FlDotCirclePainter(color: widget.blue2, radius: radius),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
List<ScatterSpot> randomData() {
|
||||
const blue1Count = 21;
|
||||
const blue2Count = 57;
|
||||
return List.generate(blue1Count + blue2Count, (i) {
|
||||
Color color;
|
||||
if (i < blue1Count) {
|
||||
color = widget.blue1;
|
||||
} else {
|
||||
color = widget.blue2;
|
||||
}
|
||||
|
||||
return ScatterSpot(
|
||||
(Random().nextDouble() * (maxX - 8)) + 4,
|
||||
(Random().nextDouble() * (maxY - 8)) + 4,
|
||||
dotPainter: FlDotCirclePainter(
|
||||
color: color,
|
||||
radius: (Random().nextDouble() * 16) + 4,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:fl_chart_app/presentation/resources/app_resources.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ScatterChartSample2 extends StatefulWidget {
|
||||
const ScatterChartSample2({super.key});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _ScatterChartSample2State();
|
||||
}
|
||||
|
||||
class _ScatterChartSample2State extends State {
|
||||
int touchedIndex = -1;
|
||||
|
||||
Color greyColor = Colors.grey;
|
||||
final _availableColors = [
|
||||
AppColors.contentColorGreen,
|
||||
AppColors.contentColorYellow,
|
||||
AppColors.contentColorPink,
|
||||
AppColors.contentColorOrange,
|
||||
AppColors.contentColorPurple,
|
||||
AppColors.contentColorBlue,
|
||||
AppColors.contentColorRed,
|
||||
AppColors.contentColorCyan,
|
||||
AppColors.contentColorBlue,
|
||||
AppColors.contentColorGreen,
|
||||
AppColors.contentColorPink,
|
||||
];
|
||||
|
||||
List<int> selectedSpots = [];
|
||||
|
||||
PainterType _currentPaintType = PainterType.circle;
|
||||
|
||||
static FlDotPainter _getPaint(PainterType type, double size, Color color) {
|
||||
switch (type) {
|
||||
case PainterType.circle:
|
||||
return FlDotCirclePainter(
|
||||
color: color,
|
||||
radius: size,
|
||||
);
|
||||
case PainterType.square:
|
||||
return FlDotSquarePainter(
|
||||
color: color,
|
||||
size: size * 2,
|
||||
strokeWidth: 0,
|
||||
);
|
||||
case PainterType.cross:
|
||||
return FlDotCrossPainter(
|
||||
color: color,
|
||||
size: size * 2,
|
||||
width: max(size / 5, 2),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// (x, y, size)
|
||||
final data = [
|
||||
(4.0, 4.0, 4.0),
|
||||
(2.0, 5.0, 12.0),
|
||||
(4.0, 5.0, 8.0),
|
||||
(8.0, 6.0, 20.0),
|
||||
(5.0, 7.0, 14.0),
|
||||
(7.0, 2.0, 18.0),
|
||||
(3.0, 2.0, 36.0),
|
||||
(2.0, 8.0, 22.0),
|
||||
(8.0, 8.0, 32.0),
|
||||
(5.0, 2.5, 24.0),
|
||||
(3.0, 7.0, 18.0),
|
||||
];
|
||||
return AspectRatio(
|
||||
aspectRatio: 1,
|
||||
child: Stack(
|
||||
children: [
|
||||
ScatterChart(
|
||||
ScatterChartData(
|
||||
scatterSpots: data.asMap().entries.map((e) {
|
||||
final index = e.key;
|
||||
final (double x, double y, double size) = e.value;
|
||||
return ScatterSpot(
|
||||
x,
|
||||
y,
|
||||
dotPainter: _getPaint(
|
||||
_currentPaintType,
|
||||
size,
|
||||
selectedSpots.contains(index)
|
||||
? _availableColors[index % _availableColors.length]
|
||||
: AppColors.contentColorWhite.withValues(alpha: 0.5),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
minX: 0,
|
||||
maxX: 10,
|
||||
minY: 0,
|
||||
maxY: 10,
|
||||
borderData: FlBorderData(
|
||||
show: false,
|
||||
),
|
||||
gridData: FlGridData(
|
||||
show: true,
|
||||
drawHorizontalLine: true,
|
||||
checkToShowHorizontalLine: (value) => true,
|
||||
getDrawingHorizontalLine: (value) => const FlLine(
|
||||
color: AppColors.gridLinesColor,
|
||||
),
|
||||
drawVerticalLine: true,
|
||||
checkToShowVerticalLine: (value) => true,
|
||||
getDrawingVerticalLine: (value) => const FlLine(
|
||||
color: AppColors.gridLinesColor,
|
||||
),
|
||||
),
|
||||
titlesData: const FlTitlesData(
|
||||
show: false,
|
||||
),
|
||||
showingTooltipIndicators: selectedSpots,
|
||||
scatterTouchData: ScatterTouchData(
|
||||
enabled: true,
|
||||
handleBuiltInTouches: false,
|
||||
mouseCursorResolver:
|
||||
(FlTouchEvent touchEvent, ScatterTouchResponse? response) {
|
||||
return response == null || response.touchedSpot == null
|
||||
? MouseCursor.defer
|
||||
: SystemMouseCursors.click;
|
||||
},
|
||||
touchTooltipData: ScatterTouchTooltipData(
|
||||
getTooltipColor: (ScatterSpot touchedBarSpot) {
|
||||
return touchedBarSpot.dotPainter.mainColor;
|
||||
},
|
||||
getTooltipItems: (ScatterSpot touchedBarSpot) {
|
||||
final bool isBgDark =
|
||||
switch ((touchedBarSpot.x, touchedBarSpot.y)) {
|
||||
(4.0, 4.0) => false,
|
||||
(2.0, 5.0) => false,
|
||||
(4.0, 5.0) => true,
|
||||
(8.0, 6.0) => true,
|
||||
(5.0, 7.0) => true,
|
||||
(7.0, 2.0) => true,
|
||||
(3.0, 2.0) => true,
|
||||
(2.0, 8.0) => false,
|
||||
(8.0, 8.0) => true,
|
||||
(5.0, 2.5) => false,
|
||||
(3.0, 7.0) => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
final color1 = isBgDark ? Colors.grey[100] : Colors.black87;
|
||||
final color2 = isBgDark ? Colors.white : Colors.black;
|
||||
return ScatterTooltipItem(
|
||||
'X: ',
|
||||
textStyle: TextStyle(
|
||||
height: 1.2,
|
||||
color: color1,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
bottomMargin: 10,
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '${touchedBarSpot.x.toInt()} \n',
|
||||
style: TextStyle(
|
||||
color: color2,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: 'Y: ',
|
||||
style: TextStyle(
|
||||
height: 1.2,
|
||||
color: color1,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: touchedBarSpot.y.toInt().toString(),
|
||||
style: TextStyle(
|
||||
color: color2,
|
||||
fontStyle: FontStyle.normal,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
touchCallback:
|
||||
(FlTouchEvent event, ScatterTouchResponse? touchResponse) {
|
||||
if (touchResponse == null ||
|
||||
touchResponse.touchedSpot == null) {
|
||||
return;
|
||||
}
|
||||
if (event is FlTapUpEvent) {
|
||||
final sectionIndex = touchResponse.touchedSpot!.spotIndex;
|
||||
setState(() {
|
||||
if (selectedSpots.contains(sectionIndex)) {
|
||||
selectedSpots.remove(sectionIndex);
|
||||
} else {
|
||||
selectedSpots.add(sectionIndex);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: DropdownButton(
|
||||
value: _currentPaintType,
|
||||
items: PainterType.values
|
||||
.map((e) => DropdownMenuItem(
|
||||
value: e,
|
||||
child: Text(e.name),
|
||||
))
|
||||
.toList(),
|
||||
onChanged: (PainterType? value) {
|
||||
setState(() {
|
||||
_currentPaintType = value!;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum PainterType {
|
||||
circle,
|
||||
square,
|
||||
cross,
|
||||
}
|
||||
Reference in New Issue
Block a user