Skip to content

Commit

Permalink
✨ Migrated package to flutter 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DhavalRKansara authored and dhaval-k-simformsolutions committed Jul 10, 2024
1 parent 1770d66 commit 5fa6eac
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 111 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- # [1.1.1] (UnReleased)
- Migrate to Flutter 3.
- Added support for double tapping gestures on any event in day, week, and month view. [#195](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/195)
- Added support for horizontal scroll physics of week and month view page. [#314](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/314)
- Fixed issue related to the live time indicator is that it is not in the correct position when startHour is set for the week and day view. [#346](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/346)
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
intl:
flutter_colorpicker: ^0.6.0
flutter_colorpicker: ^1.1.0
calendar_view:
path: ../

Expand Down
12 changes: 1 addition & 11 deletions example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@
<link rel="manifest" href="manifest.json">
</head>
<body>
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('flutter-first-frame', function () {
navigator.serviceWorker.register('flutter_service_worker.js');
});
}
</script>
<script src="main.dart.js" type="application/javascript"></script>
<script src="flutter_bootstrap.js" async></script>
</body>
</html>
6 changes: 3 additions & 3 deletions lib/src/calendar_controller_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class CalendarControllerProvider<T extends Object?> extends InheritedWidget {
/// Use this widget to provide same controller object to all calendar
/// view widgets and synchronize events between them.
const CalendarControllerProvider({
Key? key,
super.key,
required this.controller,
required Widget child,
}) : super(key: key, child: child);
required super.child,
});

static CalendarControllerProvider<T> of<T extends Object?>(
BuildContext context) {
Expand Down
16 changes: 8 additions & 8 deletions lib/src/components/_internal_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ class LiveTimeIndicator extends StatefulWidget {

/// Widget to display tile line according to current time.
const LiveTimeIndicator({
Key? key,
super.key,
required this.width,
required this.height,
required this.timeLineWidth,
required this.liveTimeIndicatorSettings,
required this.heightPerMinute,
required this.startHour,
}) : super(key: key);
});

@override
_LiveTimeIndicatorState createState() => _LiveTimeIndicatorState();
Expand Down Expand Up @@ -152,7 +152,7 @@ class TimeLine extends StatefulWidget {

/// Time line to display time at left side of day or week view.
const TimeLine({
Key? key,
super.key,
required this.timeLineWidth,
required this.hourHeight,
required this.height,
Expand All @@ -162,7 +162,7 @@ class TimeLine extends StatefulWidget {
this.showHalfHours = false,
this.showQuarterHours = false,
required this.liveTimeIndicatorSettings,
}) : super(key: key);
});

@override
State<TimeLine> createState() => _TimeLineState();
Expand Down Expand Up @@ -336,7 +336,7 @@ class EventGenerator<T extends Object?> extends StatelessWidget {

/// A widget that display event tiles in day/week view.
const EventGenerator({
Key? key,
super.key,
required this.height,
required this.width,
required this.events,
Expand All @@ -349,7 +349,7 @@ class EventGenerator<T extends Object?> extends StatelessWidget {
required this.onTileLongTap,
required this.scrollNotifier,
required this.onTileDoubleTap,
}) : super(key: key);
});

/// Arrange events and returns list of [Widget] that displays event
/// tile on display area. This method uses [eventArranger] to get position
Expand Down Expand Up @@ -464,7 +464,7 @@ class PressDetector extends StatelessWidget {

/// A widget that display event tiles in day/week view.
const PressDetector({
Key? key,
super.key,
required this.height,
required this.width,
required this.heightPerMinute,
Expand All @@ -473,7 +473,7 @@ class PressDetector extends StatelessWidget {
required this.onDateTap,
required this.minuteSlotSize,
required this.startHour,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/components/common_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CalendarPageHeader extends StatelessWidget {
/// Common header for month and day view In this header user can define format
/// in which date will be displayed by providing [dateStringBuilder] function.
const CalendarPageHeader({
Key? key,
super.key,
required this.date,
required this.dateStringBuilder,
this.onNextDay,
Expand All @@ -62,7 +62,7 @@ class CalendarPageHeader extends StatelessWidget {
@Deprecated("Use Header Style to provide icon color")
this.iconColor = Constants.black,
this.headerStyle = const HeaderStyle(),
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down
40 changes: 14 additions & 26 deletions lib/src/components/day_view_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
// Use of this source code is governed by a MIT-style license
// that can be found in the LICENSE file.

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../calendar_event_data.dart';
import '../constants.dart';
import '../extensions.dart';
import '../style/header_style.dart';
import '../typedefs.dart';
import 'common_components.dart';

Expand Down Expand Up @@ -45,7 +42,7 @@ class RoundedEventTile extends StatelessWidget {

/// This is default tile to display in day view.
const RoundedEventTile({
Key? key,
super.key,
required this.title,
this.padding = EdgeInsets.zero,
this.margin = EdgeInsets.zero,
Expand All @@ -55,7 +52,7 @@ class RoundedEventTile extends StatelessWidget {
this.backgroundColor = Colors.blue,
this.titleStyle,
this.descriptionStyle,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -118,27 +115,18 @@ class RoundedEventTile extends StatelessWidget {
class DayPageHeader extends CalendarPageHeader {
/// A header widget to display on day view.
const DayPageHeader({
Key? key,
VoidCallback? onNextDay,
AsyncCallback? onTitleTapped,
VoidCallback? onPreviousDay,
Color iconColor = Constants.black,
Color backgroundColor = Constants.headerBackground,
super.key,
super.onNextDay,
super.onTitleTapped,
super.onPreviousDay,
super.iconColor,
super.backgroundColor,
StringProvider? dateStringBuilder,
required DateTime date,
HeaderStyle headerStyle = const HeaderStyle(),
required super.date,
super.headerStyle,
}) : super(
key: key,
date: date,
// ignore_for_file: deprecated_member_use_from_same_package
backgroundColor: backgroundColor,
iconColor: iconColor,
onNextDay: onNextDay,
onPreviousDay: onPreviousDay,
onTitleTapped: onTitleTapped,
dateStringBuilder:
dateStringBuilder ?? DayPageHeader._dayStringBuilder,
headerStyle: headerStyle,
);

static String _dayStringBuilder(DateTime date, {DateTime? secondaryDate}) =>
Expand All @@ -157,11 +145,11 @@ class DefaultTimeLineMark extends StatelessWidget {

/// Time marker for timeline used in week and day view.
const DefaultTimeLineMark({
Key? key,
super.key,
required this.date,
this.markingStyle,
this.timeStringBuilder,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -191,15 +179,15 @@ class DefaultTimeLineMark extends StatelessWidget {
/// This class is defined default view of full day event
class FullDayEventView<T> extends StatelessWidget {
const FullDayEventView({
Key? key,
super.key,
this.boxConstraints = const BoxConstraints(maxHeight: 100),
required this.events,
this.padding,
this.itemView,
this.titleStyle,
this.onEventTap,
required this.date,
}) : super(key: key);
});

/// Constraints for view
final BoxConstraints boxConstraints;
Expand Down
33 changes: 12 additions & 21 deletions lib/src/components/month_view_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// Use of this source code is governed by a MIT-style license
// that can be found in the LICENSE file.

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../calendar_event_data.dart';
import '../constants.dart';
import '../extensions.dart';
import '../style/header_style.dart';
import '../typedefs.dart';
import 'common_components.dart';

Expand All @@ -34,14 +32,14 @@ class CircularCell extends StatelessWidget {
/// This class will defines how cell will be displayed.
/// To get proper view user [CircularCell] with 1 [MonthView.cellAspectRatio].
const CircularCell({
Key? key,
super.key,
required this.date,
this.events = const [],
this.shouldHighlight = false,
this.backgroundColor = Colors.blue,
this.highlightedTitleColor = Constants.white,
this.titleColor = Constants.black,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -107,7 +105,7 @@ class FilledCell<T extends Object?> extends StatelessWidget {
/// This class will defines how cell will be displayed.
/// This widget will display all the events as tile below date title.
const FilledCell({
Key? key,
super.key,
required this.date,
required this.events,
this.isInMonth = false,
Expand All @@ -122,7 +120,7 @@ class FilledCell<T extends Object?> extends StatelessWidget {
this.highlightedTitleColor = Constants.white,
this.dateStringBuilder,
this.onTileDoubleTap,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -209,27 +207,20 @@ class FilledCell<T extends Object?> extends StatelessWidget {
class MonthPageHeader extends CalendarPageHeader {
/// A header widget to display on month view.
const MonthPageHeader({
Key? key,
super.key,
VoidCallback? onNextMonth,
AsyncCallback? onTitleTapped,
super.onTitleTapped,
VoidCallback? onPreviousMonth,
Color iconColor = Constants.black,
Color backgroundColor = Constants.headerBackground,
super.iconColor,
super.backgroundColor,
StringProvider? dateStringBuilder,
required DateTime date,
HeaderStyle headerStyle = const HeaderStyle(),
required super.date,
super.headerStyle,
}) : super(
key: key,
date: date,
onNextDay: onNextMonth,
onPreviousDay: onPreviousMonth,
onTitleTapped: onTitleTapped,
// ignore_for_file: deprecated_member_use_from_same_package
backgroundColor: backgroundColor,
iconColor: iconColor,
dateStringBuilder:
dateStringBuilder ?? MonthPageHeader._monthStringBuilder,
headerStyle: headerStyle,
);

static String _monthStringBuilder(DateTime date, {DateTime? secondaryDate}) =>
Expand All @@ -254,13 +245,13 @@ class WeekDayTile extends StatelessWidget {

/// Title for week day in month view.
const WeekDayTile({
Key? key,
super.key,
required this.dayIndex,
this.backgroundColor = Constants.white,
this.displayBorder = true,
this.textStyle,
this.weekDayStringBuilder,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down
3 changes: 1 addition & 2 deletions lib/src/components/safe_area_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import 'package:flutter/material.dart';
class SafeAreaWrapper extends SafeArea {
SafeAreaWrapper({
SafeAreaOption option = const SafeAreaOption(),
required Widget child,
required super.child,
}) : super(
left: option.left,
top: option.top,
right: option.right,
bottom: option.bottom,
minimum: option.minimum,
maintainBottomViewPadding: option.maintainBottomViewPadding,
child: child,
);
}

Expand Down
27 changes: 7 additions & 20 deletions lib/src/components/week_view_components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,27 @@
// Use of this source code is governed by a MIT-style license
// that can be found in the LICENSE file.

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import '../constants.dart';
import '../style/header_style.dart';
import '../typedefs.dart';
import 'common_components.dart';

class WeekPageHeader extends CalendarPageHeader {
/// A header widget to display on week view.
const WeekPageHeader({
Key? key,
VoidCallback? onNextDay,
AsyncCallback? onTitleTapped,
VoidCallback? onPreviousDay,
super.key,
super.onNextDay,
super.onTitleTapped,
super.onPreviousDay,
required DateTime startDate,
required DateTime endDate,
Color iconColor = Constants.black,
Color backgroundColor = Constants.headerBackground,
super.iconColor,
super.backgroundColor,
StringProvider? headerStringBuilder,
HeaderStyle headerStyle = const HeaderStyle(),
super.headerStyle,
}) : super(
key: key,
date: startDate,
secondaryDate: endDate,
onNextDay: onNextDay,
onPreviousDay: onPreviousDay,
onTitleTapped: onTitleTapped,
// ignore_for_file: deprecated_member_use_from_same_package
iconColor: iconColor,
backgroundColor: backgroundColor,
dateStringBuilder:
headerStringBuilder ?? WeekPageHeader._weekStringBuilder,
headerStyle: headerStyle,
);

static String _weekStringBuilder(DateTime date, {DateTime? secondaryDate}) =>
Expand Down
Loading

0 comments on commit 5fa6eac

Please sign in to comment.