Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fixes static analysis warning in package. #327

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include: package:lints/core.yaml

analyzer:
exclude:
- example/build/**
Expand Down
1 change: 1 addition & 0 deletions example/macos/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

# Xcode-related
**/xcuserdata/
/DerivedData/
8 changes: 7 additions & 1 deletion lib/src/calendar_event_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,13 @@ class CalendarEventData<T extends Object?> {
}

@override
int get hashCode => super.hashCode;
int get hashCode =>
description.hashCode ^
descriptionStyle.hashCode ^
titleStyle.hashCode ^
color.hashCode ^
title.hashCode ^
date.hashCode;
}

/// {@template calendar_event_data_doc}
Expand Down
5 changes: 3 additions & 2 deletions lib/src/day_view/day_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
DateTime startDuration,
DateTime endDuration,
) {
if (events.isNotEmpty)
if (events.isNotEmpty) {
return RoundedEventTile(
borderRadius: BorderRadius.circular(10.0),
title: events[0].title,
Expand All @@ -682,8 +682,9 @@ class DayViewState<T extends Object?> extends State<DayView<T>> {
titleStyle: events[0].titleStyle,
descriptionStyle: events[0].descriptionStyle,
);
else
} else {
return SizedBox.shrink();
}
}

/// Default view header builder. This builder will be used if
Expand Down
2 changes: 1 addition & 1 deletion lib/src/event_arrangers/merge_event_arranger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MergeEventArranger<T extends Object?> extends EventArranger<T> {
"\n1. Start time or end time might be null"
"\n2. endTime occurs before or at the same time as startTime."
"\nEvent data: \n$event\n");
} catch (e) {} // Suppress exceptions.
} catch (e) {} // ignore:empty_catches

return true;
}(), "Can not add event in the list.");
Expand Down
2 changes: 1 addition & 1 deletion lib/src/event_arrangers/side_event_arranger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class SideEventArranger<T extends Object?> extends EventArranger<T> {
try {
debugPrint("Start time or end time of an event can not be null. "
"This ${sideEvent.event} will be ignored.");
} catch (e) {} // Suppress exceptions.
} catch (e) {} // ignore:empty_catches

return true;
}(), "Can not add event in the list.");
Expand Down
8 changes: 6 additions & 2 deletions lib/src/event_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ class EventController<T extends Object?> extends ChangeNotifier {
/// Add all the events in the list
/// If there is an event with same date then
void addAll(List<CalendarEventData<T>> events) {
for (final event in events) _calendarData.addEvent(event);
for (final event in events) {
_calendarData.addEvent(event);
}
notifyListeners();
}

Expand Down Expand Up @@ -105,7 +107,9 @@ class EventController<T extends Object?> extends ChangeNotifier {

/// Removes all the [events] from this controller.
void removeAll(List<CalendarEventData<T>> events) {
for (final event in events) _calendarData.removeEvent(event);
for (final event in events) {
_calendarData.removeEvent(event);
}
notifyListeners();
}

Expand Down
29 changes: 17 additions & 12 deletions lib/src/painters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,18 @@ class HourLinePainter extends CustomPainter {
}
}

if (showVerticalLine) if (lineStyle == LineStyle.dashed) {
var startY = 0.0;
while (startY < size.height) {
canvas.drawLine(Offset(offset + verticalLineOffset, startY),
Offset(offset + verticalLineOffset, startY + dashWidth), paint);
startY += dashWidth + dashSpaceWidth;
if (showVerticalLine) {
if (lineStyle == LineStyle.dashed) {
var startY = 0.0;
while (startY < size.height) {
canvas.drawLine(Offset(offset + verticalLineOffset, startY),
Offset(offset + verticalLineOffset, startY + dashWidth), paint);
startY += dashWidth + dashSpaceWidth;
}
} else {
canvas.drawLine(Offset(offset + verticalLineOffset, 0),
Offset(offset + verticalLineOffset, size.height), paint);
}
} else {
canvas.drawLine(Offset(offset + verticalLineOffset, 0),
Offset(offset + verticalLineOffset, size.height), paint);
}
}

Expand Down Expand Up @@ -296,11 +298,12 @@ class CurrentTimeLinePainter extends CustomPainter {
..strokeWidth = height,
);

if (showBullet)
if (showBullet) {
canvas.drawCircle(
Offset(offset.dx, offset.dy), bulletRadius, Paint()..color = color);
}

if (showTimeBackgroundView)
if (showTimeBackgroundView) {
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(
Expand All @@ -316,8 +319,9 @@ class CurrentTimeLinePainter extends CustomPainter {
..style = PaintingStyle.fill
..strokeWidth = bulletRadius,
);
}

if (showTime)
if (showTime) {
TextPainter(
textDirection: TextDirection.ltr,
text: TextSpan(
Expand All @@ -330,6 +334,7 @@ class CurrentTimeLinePainter extends CustomPainter {
)
..layout()
..paint(canvas, Offset(offset.dx - 62, offset.dy - 6));
}
}

@override
Expand Down
5 changes: 3 additions & 2 deletions lib/src/week_view/week_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
Rect boundary,
DateTime startDuration,
DateTime endDuration) {
if (events.isNotEmpty)
if (events.isNotEmpty) {
return RoundedEventTile(
borderRadius: BorderRadius.circular(6.0),
title: events[0].title,
Expand All @@ -797,8 +797,9 @@ class WeekViewState<T extends Object?> extends State<WeekView<T>> {
padding: EdgeInsets.all(7.0),
backgroundColor: events[0].color,
);
else
} else {
return Container();
}
}

/// Default view header builder. This builder will be used if
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies:
sdk: flutter

dev_dependencies:
lints: ^3.0.0
flutter_test:
sdk: flutter

Expand Down
Loading