diff --git a/.github/workflows/flutter_analyze.yml b/.github/workflows/flutter_analyze.yml
index efafd499..4a0d8c5e 100644
--- a/.github/workflows/flutter_analyze.yml
+++ b/.github/workflows/flutter_analyze.yml
@@ -23,5 +23,8 @@ jobs:
- name: Install dependencies
run: flutter pub get
+ - name: Formatting check
+ run: flutter format . --dry-run --set-exit-if-changed
+
- name: Analyse
run: flutter analyze
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..c4f39f56
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,9 @@
+# Way to contribute
+
+1. Fork the repo and create your branch from `master` or `devlop`.
+2. Clone the project to your own machine.
+3. Commit changes to your own branch
+4. Make sure your code lints.
+5. Push your work back up to your fork.
+6. Create a pull request on `devlop` branch.
+7. And Done!
\ No newline at end of file
diff --git a/flutter_calendar_page.iml b/flutter_calendar_page.iml
deleted file mode 100644
index a461e815..00000000
--- a/flutter_calendar_page.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart
index 12ca63e6..da7a1669 100644
--- a/lib/src/day_view/day_view.dart
+++ b/lib/src/day_view/day_view.dart
@@ -213,12 +213,10 @@ class DayViewState extends State> {
late DateWidgetBuilder _dayTitleBuilder;
- late EventController _controller;
+ EventController? _controller;
late ScrollController _scrollController;
- bool _controllerAdded = false;
-
late VoidCallback _reloadCallback;
final _scrollConfiguration = EventScrollConfiguration();
@@ -249,10 +247,10 @@ class DayViewState extends State> {
final newController = widget.controller ??
CalendarControllerProvider.of(context).controller;
- if (_controller != newController) {
+ if (newController != _controller) {
_controller = newController;
- _controller
+ _controller!
// Removes existing callback.
..removeListener(_reloadCallback)
@@ -261,8 +259,6 @@ class DayViewState extends State> {
..addListener(_reloadCallback);
}
- _controllerAdded = true;
-
_updateViewDimensions();
}
@@ -274,9 +270,9 @@ class DayViewState extends State> {
CalendarControllerProvider.of(context).controller;
if (newController != _controller) {
- _controller.removeListener(_reloadCallback);
+ _controller?.removeListener(_reloadCallback);
_controller = newController;
- _controller.addListener(_reloadCallback);
+ _controller?.addListener(_reloadCallback);
}
// Update date range.
@@ -301,7 +297,7 @@ class DayViewState extends State> {
@override
void dispose() {
- _controller.removeListener(_reloadCallback);
+ _controller?.removeListener(_reloadCallback);
_pageController.dispose();
super.dispose();
}
@@ -356,7 +352,7 @@ class DayViewState extends State> {
verticalLineOffset: widget.verticalLineOffset,
showVerticalLine: widget.showVerticalLine,
height: _height,
- controller: _controller,
+ controller: controller,
hourHeight: _hourHeight,
eventArranger: _eventArranger,
minuteSlotSize: widget.minuteSlotSize,
@@ -379,9 +375,11 @@ class DayViewState extends State> {
/// This will throw [AssertionError] if controller is called before its
/// initialization is complete.
EventController get controller {
- assert(_controllerAdded, "EventController is not initialized yet.");
+ if (_controller == null) {
+ throw "EventController is not initialized yet.";
+ }
- return _controller;
+ return _controller!;
}
/// Reloads page.
diff --git a/lib/src/month_view/month_view.dart b/lib/src/month_view/month_view.dart
index 3c3e3bb2..056aa42f 100644
--- a/lib/src/month_view/month_view.dart
+++ b/lib/src/month_view/month_view.dart
@@ -167,9 +167,7 @@ class MonthViewState extends State> {
late DateWidgetBuilder _headerBuilder;
- late EventController _controller;
-
- bool _controllerAdded = false;
+ EventController? _controller;
late VoidCallback _reloadCallback;
@@ -199,10 +197,10 @@ class MonthViewState extends State> {
final newController = widget.controller ??
CalendarControllerProvider.of(context).controller;
- if (_controller != newController) {
+ if (newController != _controller) {
_controller = newController;
- _controller
+ _controller!
// Removes existing callback.
..removeListener(_reloadCallback)
@@ -211,8 +209,6 @@ class MonthViewState extends State> {
..addListener(_reloadCallback);
}
- _controllerAdded = true;
-
updateViewDimensions();
}
@@ -224,9 +220,9 @@ class MonthViewState extends State> {
CalendarControllerProvider.of(context).controller;
if (newController != _controller) {
- _controller.removeListener(_reloadCallback);
+ _controller?.removeListener(_reloadCallback);
_controller = newController;
- _controller.addListener(_reloadCallback);
+ _controller?.addListener(_reloadCallback);
}
// Update date range.
@@ -246,7 +242,7 @@ class MonthViewState extends State> {
@override
void dispose() {
- _controller.removeListener(_reloadCallback);
+ _controller?.removeListener(_reloadCallback);
_pageController.dispose();
super.dispose();
}
@@ -301,7 +297,7 @@ class MonthViewState extends State> {
onDateLongPress: widget.onDateLongPress,
width: _width,
height: _height,
- controller: _controller,
+ controller: controller,
borderColor: widget.borderColor,
borderSize: widget.borderSize,
cellBuilder: _cellBuilder,
@@ -330,9 +326,11 @@ class MonthViewState extends State> {
/// This will throw [AssertionError] if controller is called before its
/// initialization is complete.
EventController get controller {
- assert(_controllerAdded, "EventController is not initialized yet.");
+ if (_controller == null) {
+ throw "EventController is not initialized yet.";
+ }
- return _controller;
+ return _controller!;
}
void _reload() {
diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart
index cc25f310..2f20a13c 100644
--- a/lib/src/week_view/week_view.dart
+++ b/lib/src/week_view/week_view.dart
@@ -211,11 +211,9 @@ class WeekViewState extends State> {
late double _weekTitleWidth;
late int _totalDaysInWeek;
- bool _controllerAdded = false;
-
late VoidCallback _reloadCallback;
- late EventController _controller;
+ EventController? _controller;
late ScrollController _scrollController;
late List _weekDays;
@@ -254,7 +252,7 @@ class WeekViewState extends State> {
if (_controller != newController) {
_controller = newController;
- _controller
+ _controller!
// Removes existing callback.
..removeListener(_reloadCallback)
@@ -263,8 +261,6 @@ class WeekViewState extends State> {
..addListener(_reloadCallback);
}
- _controllerAdded = true;
-
_updateViewDimensions();
}
@@ -276,9 +272,9 @@ class WeekViewState extends State> {
CalendarControllerProvider.of(context).controller;
if (newController != _controller) {
- _controller.removeListener(_reloadCallback);
+ _controller?.removeListener(_reloadCallback);
_controller = newController;
- _controller.addListener(_reloadCallback);
+ _controller?.addListener(_reloadCallback);
}
_setWeekDays();
@@ -305,7 +301,7 @@ class WeekViewState extends State> {
@override
void dispose() {
- _controller.removeListener(_reloadCallback);
+ _controller?.removeListener(_reloadCallback);
_pageController.dispose();
super.dispose();
}
@@ -363,12 +359,12 @@ class WeekViewState extends State> {
timeLineWidth: _timeLineWidth,
verticalLineOffset: 0,
showVerticalLine: true,
- controller: _controller,
+ controller: controller,
hourHeight: _hourHeight,
scrollController: _scrollController,
eventArranger: _eventArranger,
weekDays: _weekDays,
- minuteSlotSize: widget.minuteSlotSize,
+ minuteSlotSize: widget.minuteSlotSize,
scrollConfiguration: _scrollConfiguration,
));
},
@@ -387,9 +383,11 @@ class WeekViewState extends State> {
/// This will throw [AssertionError] if controller is called before its
/// initialization is complete.
EventController get controller {
- assert(_controllerAdded, "EventController is not initialized yet.");
+ if (_controller == null) {
+ throw "EventController is not initialized yet.";
+ }
- return _controller;
+ return _controller!;
}
/// Reloads page.