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

I can't handle event added with EventController #78

Closed
Timememory6 opened this issue Jun 15, 2022 · 2 comments
Closed

I can't handle event added with EventController #78

Timememory6 opened this issue Jun 15, 2022 · 2 comments
Labels
question Further information is requested

Comments

@Timememory6
Copy link

The event I added with EventController seem not to work and the event won't be shown. Please tell me how to make it work.
I want you to tell me how to use this EventController with another MonthCalendar. I wish I use riverpod for it.
class WeekCalendar extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: WeekView( controller: EventController(), 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: 400, // width of week view. heightPerMinute: 1, // height occupied by 1 minute time span. eventArranger: SideEventArranger(), // To define how simultaneous events will be arranged. onDateLongPress: (time) { try { final event = CalendarEventData( date: DateTime(2022, 6, 17), startTime: DateTime(2022, 6, 17, 15), endTime: DateTime(2022, 6, 17, 18), event: "Event 1", title: 'test', ); EventController().add(event); print(EventController().getEventsOnDay(DateTime(2022, 6, 17))); } catch (e) { print(e); } }, */ )); } }

@PRBaraiya
Copy link
Collaborator

@Timememory6 You are creating new instance of EventController every time. That won't work. You have to create only one instance of EventController and pass it to WeekView. Also, Use same instance to add events as well.
ex,

class WeekCalendar extends StatelessWidget {
  final controller = EventController();

  @override Widget build(BuildContext context) { 
    return Scaffold( 
      body: WeekView( 
        controller: controller, 
        showLiveTimeLineInAllDays: true, 
        width: 400, 
        heightPerMinute: 1,  
        eventArranger: SideEventArranger(), 
        onDateLongPress: (time) { 
          try { 
            final event = CalendarEventData( 
              date: DateTime(2022, 6, 17), 
              startTime: DateTime(2022, 6, 17, 15), 
              endTime: DateTime(2022, 6, 17, 18), 
              event: "Event 1", 
              title: 'test', 
            ); 
            controller.add(event); 
            print(controller.getEventsOnDay(DateTime(2022, 6, 17))); 
          } catch (e) { 
            print(e); 
          }         
        },
      ),
    ); 
  } 
}

@PRBaraiya PRBaraiya added question Further information is requested waiting-for-resoponse Waiting for someone to respond. labels Jul 29, 2022
@ParthBaraiya
Copy link
Collaborator

Please, let us know if this issue is resolved by above example.

@ParthBaraiya ParthBaraiya removed the waiting-for-resoponse Waiting for someone to respond. label Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants