Skip to content

Commit b255d6e

Browse files
committed
FLUT-884481-[others][flutter]: Addressed review suggestions
1 parent 16b1820 commit b255d6e

File tree

1 file changed

+87
-83
lines changed

1 file changed

+87
-83
lines changed

lib/main.dart

Lines changed: 87 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import 'package:google_generative_ai/google_generative_ai.dart';
44

55
/// Chart import.
66
import 'package:syncfusion_flutter_charts/charts.dart';
7-
import 'package:syncfusion_flutter_core/theme.dart';
87

98
void main() {
109
runApp(const MyApp());
@@ -165,7 +164,10 @@ class AIDataPreProcessingState extends State<AIDataPreProcessing>
165164
maximum: DateTime(2020, 1, 25, 24, 00),
166165
interval: 1,
167166
dateFormat: DateFormat().add_H(),
168-
majorGridLines: const MajorGridLines(dashArray: [4, 4, 4]),
167+
majorGridLines: const MajorGridLines(
168+
dashArray: [8, 8],
169+
width: 0.8,
170+
),
169171
title: AxisTitle(
170172
text: 'Time during 25th January 2020',
171173
textStyle: TextStyle(fontWeight: FontWeight.bold),
@@ -183,7 +185,7 @@ class AIDataPreProcessingState extends State<AIDataPreProcessing>
183185
interval: 200,
184186
majorGridLines: MajorGridLines(width: 0),
185187
title: AxisTitle(
186-
text: 'Traffic count',
188+
text: 'Traffic Count',
187189
textStyle: TextStyle(fontWeight: FontWeight.bold),
188190
),
189191
),
@@ -198,7 +200,86 @@ class AIDataPreProcessingState extends State<AIDataPreProcessing>
198200
args.chartPointInfo.chartPoint!.color = args.chartPointInfo.color;
199201
}
200202
},
201-
trackballBehavior: _CustomTrackballBehavior(),
203+
trackballBehavior: TrackballBehavior(
204+
enable: true,
205+
activationMode: ActivationMode.singleTap,
206+
tooltipSettings: InteractiveTooltip(
207+
arrowWidth: 0,
208+
arrowLength: 0,
209+
),
210+
markerSettings: TrackballMarkerSettings(
211+
markerVisibility: TrackballVisibilityMode.visible,
212+
borderWidth: 2.5,
213+
),
214+
builder: (BuildContext context, TrackballDetails trackballDetails) {
215+
return Container(
216+
decoration: BoxDecoration(
217+
color: Colors.blueGrey.shade100,
218+
borderRadius: BorderRadius.all(Radius.circular(5)),
219+
),
220+
child: Padding(
221+
padding: EdgeInsets.all(10),
222+
child: Row(
223+
mainAxisSize: MainAxisSize.min,
224+
spacing: 10,
225+
children: [
226+
Column(
227+
mainAxisSize: MainAxisSize.min,
228+
children: [
229+
Center(
230+
child: Container(
231+
width: 12,
232+
height: 12,
233+
decoration: BoxDecoration(
234+
shape: BoxShape.circle,
235+
color: trackballDetails.point!.color!,
236+
),
237+
),
238+
),
239+
],
240+
),
241+
Column(
242+
mainAxisSize: MainAxisSize.min,
243+
crossAxisAlignment: CrossAxisAlignment.start,
244+
spacing: 5,
245+
children: [
246+
Row(
247+
mainAxisSize: MainAxisSize.min,
248+
children: [
249+
Text(
250+
'Time Stamp : ',
251+
style: TextStyle(
252+
fontWeight: FontWeight.bold,
253+
),
254+
),
255+
Text(
256+
DateFormat('DD-MM-yyyy HH:mm:ss')
257+
.format(trackballDetails.point!.x),
258+
),
259+
],
260+
),
261+
Row(
262+
mainAxisSize: MainAxisSize.min,
263+
children: [
264+
Text(
265+
'Traffic Count : ',
266+
style: TextStyle(
267+
fontWeight: FontWeight.bold,
268+
),
269+
),
270+
Text(
271+
'${trackballDetails.point!.y}',
272+
),
273+
],
274+
),
275+
],
276+
),
277+
],
278+
),
279+
),
280+
);
281+
},
282+
),
202283
series: _buildSpLineSeries(),
203284
);
204285
}
@@ -221,7 +302,6 @@ class AIDataPreProcessingState extends State<AIDataPreProcessing>
221302
String _generatePrompt() {
222303
final String rules =
223304
'Only include values in the yyyy-MM-dd-HH-m-ss:Value format,'
224-
'Value should calculate between range from 600 to 1400'
225305
'and ensure they strictly adhere to this format without any additional explanations.'
226306
'Unwanted content should be strictly avoided.';
227307

@@ -324,7 +404,7 @@ class _AIButtonState extends State<_AIButton>
324404
with SingleTickerProviderStateMixin {
325405
late AnimationController _controller;
326406
late Animation<double> _animation;
327-
bool _isPressed = false; // Track the pressed state
407+
bool _isPressed = false; // Track the pressed state.
328408

329409
@override
330410
void initState() {
@@ -382,6 +462,7 @@ class _AIButtonState extends State<_AIButton>
382462
@override
383463
void dispose() {
384464
_controller.dispose();
465+
_isPressed = false;
385466
super.dispose();
386467
}
387468
}
@@ -393,80 +474,3 @@ class _WebTraffic {
393474
final double? trafficCount;
394475
Color? color;
395476
}
396-
397-
// ignore: must_be_immutable
398-
class _CustomTrackballBehavior extends TrackballBehavior {
399-
@override
400-
bool get enable => true;
401-
402-
@override
403-
ActivationMode get activationMode => ActivationMode.singleTap;
404-
405-
@override
406-
Color? get lineColor => Colors.transparent;
407-
408-
@override
409-
InteractiveTooltip get tooltipSettings => InteractiveTooltip(
410-
arrowWidth: 0,
411-
arrowLength: 0,
412-
);
413-
414-
@override
415-
ChartTrackballBuilder? get builder {
416-
return (BuildContext context, TrackballDetails trackballDetails) {
417-
return Container(
418-
decoration: BoxDecoration(
419-
color: Colors.grey.shade200,
420-
borderRadius: BorderRadius.all(Radius.circular(5)),
421-
),
422-
child: Padding(
423-
padding: EdgeInsets.all(10),
424-
child: Column(
425-
mainAxisSize: MainAxisSize.min,
426-
crossAxisAlignment: CrossAxisAlignment.start,
427-
spacing: 5,
428-
children: [
429-
Text(
430-
'Time Stamp : ${DateFormat('DD-MM-yyyy HH:mm:ss').format(trackballDetails.point!.x)}',
431-
style: TextStyle(color: trackballDetails.point!.color),
432-
),
433-
Text(
434-
'Traffic Count : ${trackballDetails.point!.y}',
435-
style: TextStyle(color: trackballDetails.point!.color),
436-
),
437-
],
438-
),
439-
),
440-
);
441-
};
442-
}
443-
444-
@override
445-
void onPaint(PaintingContext context, Offset offset,
446-
SfChartThemeData chartThemeData, ThemeData themeData) {
447-
super.onPaint(context, offset, chartThemeData, themeData);
448-
449-
if (chartPointInfo.isEmpty || parentBox == null) {
450-
return;
451-
}
452-
453-
final int length = chartPointInfo.length;
454-
for (int i = 0; i < length; i++) {
455-
final Offset position =
456-
Offset(chartPointInfo[i].xPosition!, chartPointInfo[i].yPosition!);
457-
context.canvas.drawCircle(
458-
position,
459-
8,
460-
Paint()
461-
..style = PaintingStyle.fill
462-
..color = chartPointInfo[i].color!);
463-
context.canvas.drawCircle(
464-
position,
465-
8,
466-
Paint()
467-
..style = PaintingStyle.stroke
468-
..strokeWidth = 2
469-
..color = Colors.white);
470-
}
471-
}
472-
}

0 commit comments

Comments
 (0)