Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WeekView not showing events #153

Closed
danPyk opened this issue Dec 19, 2022 · 3 comments
Closed

WeekView not showing events #153

danPyk opened this issue Dec 19, 2022 · 3 comments

Comments

@danPyk
Copy link

danPyk commented Dec 19, 2022

I've used MonthView from your package, it works preety well, but now I wanted to use WeekView and events are not showing.
Here's code, basiclly copy-paste from example:

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  
  @override
  Widget build(BuildContext context) {

    final event = CalendarEventData(
      date: DateTime(2022, 12, 19),
      endDate: DateTime(2022,12,21),
      event: "Event 1",
      title: 'title'
    );

    return Scaffold(
      appBar: AppBar(

        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: WeekView(
        controller: EventController()..add(event),
        eventTileBuilder: (date, events, boundry, start, end) {
          // Return your widget to display as event tile.
          return Container();
        },
        showLiveTimeLineInAllDays: true, // To display live time line in all pages in week view.
        width: 250, // width of week view.
        minDay: DateTime(1990),
        maxDay: DateTime(2050),
        initialDay: DateTime(2021),
        heightPerMinute: 1, // height occupied by 1 minute time span.
        eventArranger: SideEventArranger(), // To define how simultaneous events will be arranged.
        onEventTap: (events, date) => print(events),
        onDateLongPress: (date) => print(date),
        startDay: WeekDays.sunday, // To change the first day of the week.
      )
    );
  }
}

@faiyaz-shaikh
Copy link
Contributor

@danPyk As per code you have shared, In the event you have not added startTime and endTime of the event also you returning empty container on eventTileBuilder. Please assign startTime and endTime to the event and make sure you are not returning empty widget to eventTileBuilder.

@PRBaraiya
Copy link
Collaborator

@danPyk I'm closing this issue for now. Feel free to reopen the issue if the above solution does not work.

@danPyk
Copy link
Author

danPyk commented Jan 9, 2023

@faiyaz-shaikh Thank you for replay.
Looks like I've missed comment talking about creating event, which is little embarrassing, because It was in posted code, but when I've used MonthView, I only needed date and endDate, so I thought in WeekView it'll be the same.

If I can suggest, it would be great design thing, to be able, to replace week view, with month view, and vice versa, without making any additional changes.

I have applied your advices, but I'm still do not see events.

class _MyHomePageState extends State<MyHomePage> {
  
  @override
  Widget build(BuildContext context) {

    final event = CalendarEventData(
      date: DateTime(2023, 01, 01),
      endDate: DateTime(2023,01,7),
      startTime: DateTime(2023, 01, 01),
     endTime: DateTime(2023,01,7),
      event: "Event 1",
      title: 'title'
    );

    return Scaffold(
      appBar: AppBar(

        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: WeekView(
        controller: EventController()..add(event),
        eventTileBuilder: (date, events, boundry, start, end) {
          // Return your widget to display as event tile.
          return Container(height: 100, width: 100, child: Text(date.toString()),);
        },
        showLiveTimeLineInAllDays: true, // To display live time line in all pages in week view.
        width: 250, // width of week view.
        minDay: DateTime(1990),
        maxDay: DateTime(2050),
        initialDay: DateTime(2023),
        heightPerMinute: 1, // height occupied by 1 minute time span.
        eventArranger: SideEventArranger(), // To define how simultaneous events will be arranged.
        onEventTap: (events, date) => print(events),
        onDateLongPress: (date) => print(date),
        startDay: WeekDays.sunday, // To change the first day of the week.
      )
    );
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants