-
Notifications
You must be signed in to change notification settings - Fork 308
Open
Description
When I create an weekly event, it seems to behave differently than other recurring events.
Example
When adding events with the all different frequencies to the start of the month, only the weekly event is shifted by one day.
Code
// main.dart
import 'package:calendar_view/calendar_view.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text("CalendarView Test"), centerTitle: true),
body: SafeArea(child: CalendarViewTest()),
),
);
}
}
class CalendarViewTest extends StatelessWidget {
const CalendarViewTest({super.key});
@override
Widget build(BuildContext context) {
final EventController eventController = EventController();
eventController.addAll(RepeatFrequency.values.map(createEvent).toList());
return CalendarControllerProvider(
controller: eventController,
child: DefaultTabController(
length: 3,
child: Scaffold(
appBar: TabBar(
tabs: [
Tab(text: "Month"),
Tab(text: "Week"),
Tab(text: "Day"),
],
),
body: TabBarView(
children: [
MonthView(
controller: eventController,
useAvailableVerticalSpace: true,
),
WeekView(controller: eventController),
DayView(controller: eventController),
],
),
),
),
);
}
}
CalendarEventData createEvent(RepeatFrequency frequency) {
DateTime firstOfMonth = DateTime.now().withoutTime.copyWith(day: 1);
return CalendarEventData(
title: frequency.name,
date: firstOfMonth,
recurrenceSettings: RecurrenceSettings(
startDate: firstOfMonth,
frequency: frequency,
),
);
}Metadata
Metadata
Assignees
Labels
No labels
