Skip to content

Commit fe3ad39

Browse files
FLUT-897874-[others]: Updated the code
1 parent 6204e37 commit fe3ad39

File tree

1 file changed

+21
-49
lines changed

1 file changed

+21
-49
lines changed

lib/main.dart

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,28 @@ class MyApp extends StatefulWidget {
1111
class _MyAppState extends State<MyApp> {
1212
double _needleValue = 4000;
1313

14-
void _updateNeedleValue(double value) {
14+
void _updateNeedleValue(double value) {
1515
setState(() {
1616
_needleValue = double.parse(value.toStringAsFixed(2));
1717
});
1818
}
1919

20+
// Helper method to create a WidgetPointer with value and text
21+
WidgetPointer _buildWidgetPointer(double value, double offset, String text) {
22+
return WidgetPointer(
23+
value: value,
24+
offsetUnit: GaugeSizeUnit.logicalPixel,
25+
offset: offset,
26+
child: Text(
27+
text,
28+
style: const TextStyle(
29+
fontWeight: FontWeight.bold,
30+
fontSize: 18,
31+
),
32+
),
33+
);
34+
}
35+
2036
@override
2137
Widget build(BuildContext context) {
2238
return SfRadialGauge(
@@ -60,54 +76,10 @@ class _MyAppState extends State<MyApp> {
6076
}
6177
},
6278
),
63-
const WidgetPointer(
64-
value: 0,
65-
offsetUnit: GaugeSizeUnit.logicalPixel,
66-
offset: -55,
67-
child: Text(
68-
'0',
69-
style: TextStyle(
70-
fontWeight: FontWeight.bold,
71-
fontSize: 18,
72-
),
73-
),
74-
),
75-
const WidgetPointer(
76-
value: 2000,
77-
offsetUnit: GaugeSizeUnit.logicalPixel,
78-
offset: -75,
79-
child: Text(
80-
'2000',
81-
style: TextStyle(
82-
fontWeight: FontWeight.bold,
83-
fontSize: 18,
84-
),
85-
),
86-
),
87-
const WidgetPointer(
88-
value: 6000,
89-
offsetUnit: GaugeSizeUnit.logicalPixel,
90-
offset: -75,
91-
child: Text(
92-
'6000',
93-
style: TextStyle(
94-
fontWeight: FontWeight.bold,
95-
fontSize: 18,
96-
),
97-
),
98-
),
99-
const WidgetPointer(
100-
value: 8000,
101-
offsetUnit: GaugeSizeUnit.logicalPixel,
102-
offset: -55,
103-
child: Text(
104-
'8000',
105-
style: TextStyle(
106-
fontWeight: FontWeight.bold,
107-
fontSize: 18,
108-
),
109-
),
110-
),
79+
_buildWidgetPointer(0, -55, '0'),
80+
_buildWidgetPointer(2000, -75, '2000'),
81+
_buildWidgetPointer(6000, -75, '6000'),
82+
_buildWidgetPointer(8000, -55, '8000'),
11183
],
11284
annotations: <GaugeAnnotation>[
11385
GaugeAnnotation(

0 commit comments

Comments
 (0)