From 5fa6eacf2943329fba2ab1a51f781f866d06bbf2 Mon Sep 17 00:00:00 2001 From: Dhaval Kansara Date: Fri, 4 Aug 2023 18:14:56 +0530 Subject: [PATCH] :sparkles: Migrated package to flutter 3.0 --- CHANGELOG.md | 1 + example/pubspec.yaml | 2 +- example/web/index.html | 12 +----- lib/src/calendar_controller_provider.dart | 6 +-- lib/src/components/_internal_components.dart | 16 ++++---- lib/src/components/common_components.dart | 4 +- lib/src/components/day_view_components.dart | 40 +++++++------------ lib/src/components/month_view_components.dart | 33 ++++++--------- lib/src/components/safe_area_wrapper.dart | 3 +- lib/src/components/week_view_components.dart | 27 ++++--------- lib/src/day_view/_internal_day_view_page.dart | 4 +- lib/src/day_view/day_view.dart | 5 +-- lib/src/month_view/month_view.dart | 11 +++-- .../week_view/_internal_week_view_page.dart | 4 +- lib/src/week_view/week_view.dart | 5 +-- pubspec.yaml | 2 +- 16 files changed, 64 insertions(+), 111 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2c885f7..a59ee10e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 0a1fba67..b8cf967d 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -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: ../ diff --git a/example/web/index.html b/example/web/index.html index 2bc631d9..c81b79fb 100644 --- a/example/web/index.html +++ b/example/web/index.html @@ -30,16 +30,6 @@ - - - + diff --git a/lib/src/calendar_controller_provider.dart b/lib/src/calendar_controller_provider.dart index b4b85ea5..381cc34d 100644 --- a/lib/src/calendar_controller_provider.dart +++ b/lib/src/calendar_controller_provider.dart @@ -13,10 +13,10 @@ class CalendarControllerProvider 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 of( BuildContext context) { diff --git a/lib/src/components/_internal_components.dart b/lib/src/components/_internal_components.dart index 55a69cdb..2373d66b 100644 --- a/lib/src/components/_internal_components.dart +++ b/lib/src/components/_internal_components.dart @@ -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(); @@ -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, @@ -162,7 +162,7 @@ class TimeLine extends StatefulWidget { this.showHalfHours = false, this.showQuarterHours = false, required this.liveTimeIndicatorSettings, - }) : super(key: key); + }); @override State createState() => _TimeLineState(); @@ -336,7 +336,7 @@ class EventGenerator 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, @@ -349,7 +349,7 @@ class EventGenerator 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 @@ -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, @@ -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) { diff --git a/lib/src/components/common_components.dart b/lib/src/components/common_components.dart index 227fc001..2b0cd48a 100644 --- a/lib/src/components/common_components.dart +++ b/lib/src/components/common_components.dart @@ -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, @@ -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) { diff --git a/lib/src/components/day_view_components.dart b/lib/src/components/day_view_components.dart index 98eb623e..fa33b1ed 100644 --- a/lib/src/components/day_view_components.dart +++ b/lib/src/components/day_view_components.dart @@ -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'; @@ -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, @@ -55,7 +52,7 @@ class RoundedEventTile extends StatelessWidget { this.backgroundColor = Colors.blue, this.titleStyle, this.descriptionStyle, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -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}) => @@ -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) { @@ -191,7 +179,7 @@ class DefaultTimeLineMark extends StatelessWidget { /// This class is defined default view of full day event class FullDayEventView extends StatelessWidget { const FullDayEventView({ - Key? key, + super.key, this.boxConstraints = const BoxConstraints(maxHeight: 100), required this.events, this.padding, @@ -199,7 +187,7 @@ class FullDayEventView extends StatelessWidget { this.titleStyle, this.onEventTap, required this.date, - }) : super(key: key); + }); /// Constraints for view final BoxConstraints boxConstraints; diff --git a/lib/src/components/month_view_components.dart b/lib/src/components/month_view_components.dart index 33f00993..67e38f81 100644 --- a/lib/src/components/month_view_components.dart +++ b/lib/src/components/month_view_components.dart @@ -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'; @@ -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) { @@ -107,7 +105,7 @@ class FilledCell 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, @@ -122,7 +120,7 @@ class FilledCell extends StatelessWidget { this.highlightedTitleColor = Constants.white, this.dateStringBuilder, this.onTileDoubleTap, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -209,27 +207,20 @@ class FilledCell 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}) => @@ -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) { diff --git a/lib/src/components/safe_area_wrapper.dart b/lib/src/components/safe_area_wrapper.dart index b62f21f5..26cebb6e 100644 --- a/lib/src/components/safe_area_wrapper.dart +++ b/lib/src/components/safe_area_wrapper.dart @@ -3,7 +3,7 @@ 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, @@ -11,7 +11,6 @@ class SafeAreaWrapper extends SafeArea { bottom: option.bottom, minimum: option.minimum, maintainBottomViewPadding: option.maintainBottomViewPadding, - child: child, ); } diff --git a/lib/src/components/week_view_components.dart b/lib/src/components/week_view_components.dart index 69f88203..2cdb882c 100644 --- a/lib/src/components/week_view_components.dart +++ b/lib/src/components/week_view_components.dart @@ -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}) => diff --git a/lib/src/day_view/_internal_day_view_page.dart b/lib/src/day_view/_internal_day_view_page.dart index 0faafa0e..4815e0c1 100644 --- a/lib/src/day_view/_internal_day_view_page.dart +++ b/lib/src/day_view/_internal_day_view_page.dart @@ -123,7 +123,7 @@ class InternalDayViewPage extends StatelessWidget { /// Defines a single day page. const InternalDayViewPage({ - Key? key, + super.key, required this.showVerticalLine, required this.width, required this.date, @@ -157,7 +157,7 @@ class InternalDayViewPage extends StatelessWidget { required this.quarterHourIndicatorSettings, required this.emulateVerticalOffsetBy, required this.onTileDoubleTap, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart index ffe045c0..b7cc8b72 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -225,7 +225,7 @@ class DayView extends StatefulWidget { /// Main widget for day view. const DayView({ - Key? key, + super.key, this.eventTileBuilder, this.dateStringBuilder, this.timeStringBuilder, @@ -285,8 +285,7 @@ class DayView extends StatefulWidget { dayDetectorBuilder == null || onDateLongPress == null, """If you use [dayPressDetectorBuilder] do not provide [onDateLongPress]""", - ), - super(key: key); + ); @override DayViewState createState() => DayViewState(); diff --git a/lib/src/month_view/month_view.dart b/lib/src/month_view/month_view.dart index 4c62e989..dd83977e 100644 --- a/lib/src/month_view/month_view.dart +++ b/lib/src/month_view/month_view.dart @@ -163,7 +163,7 @@ class MonthView extends StatefulWidget { /// Main [Widget] to display month view. const MonthView({ - Key? key, + super.key, this.showBorder = true, this.borderColor = Constants.defaultBorderColor, this.cellBuilder, @@ -194,9 +194,8 @@ class MonthView extends StatefulWidget { this.pagePhysics = const ClampingScrollPhysics(), this.pageViewPhysics, this.onEventDoubleTap, - }) : assert(!(onHeaderTitleTap != null && headerBuilder != null), - "can't use [onHeaderTitleTap] & [headerBuilder] simultaneously"), - super(key: key); + }) : assert(!(onHeaderTitleTap != null && headerBuilder != null), + "can't use [onHeaderTitleTap] & [headerBuilder] simultaneously"); @override MonthViewState createState() => MonthViewState(); @@ -629,7 +628,7 @@ class _MonthPageBuilder extends StatelessWidget { final ScrollPhysics physics; const _MonthPageBuilder({ - Key? key, + super.key, required this.cellRatio, required this.showBorder, required this.borderSize, @@ -643,7 +642,7 @@ class _MonthPageBuilder extends StatelessWidget { required this.onDateLongPress, required this.startDay, required this.physics, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/src/week_view/_internal_week_view_page.dart b/lib/src/week_view/_internal_week_view_page.dart index fb5e711b..9797e53a 100644 --- a/lib/src/week_view/_internal_week_view_page.dart +++ b/lib/src/week_view/_internal_week_view_page.dart @@ -143,7 +143,7 @@ class InternalWeekViewPage extends StatelessWidget { /// A single page for week view. const InternalWeekViewPage({ - Key? key, + super.key, required this.showVerticalLine, required this.weekTitleHeight, required this.weekDayBuilder, @@ -183,7 +183,7 @@ class InternalWeekViewPage extends StatelessWidget { required this.showQuarterHours, required this.emulateVerticalOffsetBy, required this.onTileDoubleTap, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index 83b97563..a36b305c 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -230,7 +230,7 @@ class WeekView extends StatefulWidget { /// Main widget for week view. const WeekView({ - Key? key, + super.key, this.controller, this.eventTileBuilder, this.pageTransitionDuration = const Duration(milliseconds: 300), @@ -296,8 +296,7 @@ class WeekView extends StatefulWidget { weekDetectorBuilder == null || onDateLongPress == null, """If you use [weekPressDetectorBuilder] do not provide [onDateLongPress]""", - ), - super(key: key); + ); @override WeekViewState createState() => WeekViewState(); diff --git a/pubspec.yaml b/pubspec.yaml index edbfd6fc..e489221e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view issue_tracker: https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues?q=is%3Aissue+is%3Aopen+label%3Abug environment: - sdk: ">=2.15.0 <4.0.0" + sdk: '>=3.0.0-0 <4.0.0' flutter: ">=1.17.0" dependencies: