From 41ffe81ecb3e45a63ca0cbda9685a76c39acdf8e 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 | 3 ++ 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 | 25 ++++-------- 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, 66 insertions(+), 109 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64b04e1c..5bc0f93e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# [1.3.0] (UnReleased) +- Migrate to Flutter 3. + # [1.2.0 - 10 May 2024](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.2.0) - Fixed issue when adding full-day events to WeekView, event is not display at correct date. [#259](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/259) diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 94dd2276..82d950c8 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -29,7 +29,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 129e84c1..4dba03fe 100644 --- a/lib/src/components/_internal_components.dart +++ b/lib/src/components/_internal_components.dart @@ -43,7 +43,7 @@ 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, @@ -51,7 +51,7 @@ class LiveTimeIndicator extends StatefulWidget { required this.heightPerMinute, required this.startHour, this.endHour = Constants.hoursADay, - }) : super(key: key); + }); @override _LiveTimeIndicatorState createState() => _LiveTimeIndicatorState(); @@ -169,7 +169,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, @@ -180,7 +180,7 @@ class TimeLine extends StatefulWidget { this.showQuarterHours = false, required this.liveTimeIndicatorSettings, this.endHour = Constants.hoursADay, - }) : super(key: key); + }); @override State createState() => _TimeLineState(); @@ -357,7 +357,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, @@ -371,7 +371,7 @@ class EventGenerator extends StatelessWidget { required this.scrollNotifier, required this.onTileDoubleTap, this.endHour = Constants.hoursADay, - }) : super(key: key); + }); /// Arrange events and returns list of [Widget] that displays event /// tile on display area. This method uses [eventArranger] to get position @@ -486,7 +486,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, @@ -495,7 +495,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 745a19b1..e8037e93 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, @@ -201,7 +189,7 @@ class FullDayEventView extends StatelessWidget { required this.date, this.onEventDoubleTap, this.onEventLongPress, - }) : 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 f64c0016..89270478 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) { @@ -110,7 +108,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, @@ -126,7 +124,7 @@ class FilledCell extends StatelessWidget { this.highlightedTitleColor = Constants.white, this.dateStringBuilder, this.onTileDoubleTap, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -213,27 +211,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}) => @@ -258,13 +249,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 77e1ff70..f200611a 100644 --- a/lib/src/components/week_view_components.dart +++ b/lib/src/components/week_view_components.dart @@ -2,40 +2,29 @@ // 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 d46be383..a76a9200 100644 --- a/lib/src/day_view/_internal_day_view_page.dart +++ b/lib/src/day_view/_internal_day_view_page.dart @@ -135,7 +135,7 @@ class InternalDayViewPage extends StatefulWidget { /// Defines a single day page. const InternalDayViewPage({ - Key? key, + super.key, required this.showVerticalLine, required this.width, required this.date, @@ -173,7 +173,7 @@ class InternalDayViewPage extends StatefulWidget { required this.emulateVerticalOffsetBy, required this.onTileDoubleTap, this.keepScrollOffset = false, - }) : super(key: key); + }); @override _InternalDayViewPageState createState() => _InternalDayViewPageState(); diff --git a/lib/src/day_view/day_view.dart b/lib/src/day_view/day_view.dart index 163b8937..ec719383 100644 --- a/lib/src/day_view/day_view.dart +++ b/lib/src/day_view/day_view.dart @@ -231,7 +231,7 @@ class DayView extends StatefulWidget { /// Main widget for day view. const DayView({ - Key? key, + super.key, this.eventTileBuilder, this.dateStringBuilder, this.timeStringBuilder, @@ -301,8 +301,7 @@ class DayView extends StatefulWidget { assert( endHour <= Constants.hoursADay || endHour < startHour, "End hour must be less than 24 or startHour must be less than endHour", - ), - 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 236fb73e..7738ada3 100644 --- a/lib/src/month_view/month_view.dart +++ b/lib/src/month_view/month_view.dart @@ -172,7 +172,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, @@ -205,9 +205,8 @@ class MonthView extends StatefulWidget { this.onEventDoubleTap, this.showWeekTileBorder = true, this.hideDaysNotInMonth = false, - }) : 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(); @@ -661,7 +660,7 @@ class _MonthPageBuilder extends StatelessWidget { final bool hideDaysNotInMonth; const _MonthPageBuilder({ - Key? key, + super.key, required this.cellRatio, required this.showBorder, required this.borderSize, @@ -676,7 +675,7 @@ class _MonthPageBuilder extends StatelessWidget { required this.startDay, required this.physics, required this.hideDaysNotInMonth, - }) : 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 2603e890..1b7d7467 100644 --- a/lib/src/week_view/_internal_week_view_page.dart +++ b/lib/src/week_view/_internal_week_view_page.dart @@ -162,7 +162,7 @@ class InternalWeekViewPage extends StatefulWidget { /// A single page for week view. const InternalWeekViewPage({ - Key? key, + super.key, required this.showVerticalLine, required this.weekTitleHeight, required this.weekDayBuilder, @@ -208,7 +208,7 @@ class InternalWeekViewPage extends StatefulWidget { required this.weekViewScrollController, this.lastScrollOffset = 0.0, this.keepScrollOffset = false, - }) : super(key: key); + }); @override _InternalWeekViewPageState createState() => _InternalWeekViewPageState(); diff --git a/lib/src/week_view/week_view.dart b/lib/src/week_view/week_view.dart index dd61214c..1583bf26 100644 --- a/lib/src/week_view/week_view.dart +++ b/lib/src/week_view/week_view.dart @@ -242,7 +242,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), @@ -320,8 +320,7 @@ class WeekView extends StatefulWidget { assert( endHour <= Constants.hoursADay || endHour < startHour, "End hour must be less than 24 or startHour must be less than endHour", - ), - super(key: key); + ); @override WeekViewState createState() => WeekViewState(); diff --git a/pubspec.yaml b/pubspec.yaml index ee773355..ffd77a47 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: