Skip to content

DayView doesn't rebuild when changing content. #14

Closed

Description

@kuemme01

Describe the bug
The DayView widget doesn't rebuild after changing content via state.

Code snippet

Widget _buildDayView() {
    List<FlutterWeekViewEvent> meetings = selectedWeekDay.meetings.map((meeting) {
      print('Meeting: ${meeting.title}, date: ${meeting.startDate}');
      return FlutterWeekViewEvent(
        title: meeting.title,
        description: meeting.description,
        start: meeting.startDate,
        end: meeting.endDate,
      );
    }).toList();

    print('Meetingscount: ${meetings.length}');
    print('SelectedDate: ${selectedWeekDay.date}');

    var dayView = DayView(
      date: selectedWeekDay.date,
      events: meetings,
    );

    print('DayEvents: ${dayView.events}');

    return dayView;
}

Console

- I/flutter ( 8800): Meeting: Meeting 1 , date: 2020-02-17 10:00:00.000
- I/flutter ( 8800): Meeting: Meeting 2 , date: 2020-02-17 11:00:00.000
- I/flutter ( 8800): Meeting: Meeting 3 , date: 2020-02-17 13:00:00.000
- I/flutter ( 8800): Meetingscount: 3
- I/flutter ( 8800): SelectedDate: 2020-02-17 00:00:00.000Z
- I/flutter ( 8800): DayEvents: [Instance of 'FlutterWeekViewEvent', Instance of 'FlutterWeekViewEvent', Instance of 'FlutterWeekViewEvent']

After changing date via state:

- I/flutter ( 8800): Meeting: Meeting 4 , date: 2020-02-18 10:00:00.000
- I/flutter ( 8800): Meeting: Meeting 5 , date: 2020-02-18 13:00:00.000
- I/flutter ( 8800): Meetingscount: 2
- I/flutter ( 8800): SelectedDate: 2020-02-18 00:00:00.000Z
- I/flutter ( 8800): DayEvents: [Instance of 'FlutterWeekViewEvent', Instance of 'FlutterWeekViewEvent']

Expected behavior
DayView should rebuild its content.

Tablet (please complete the following information):

  • OS: Android
  • Version 9

Activity

  1. kuemme01 commented on Feb 17, 2020

    @kuemme01
    Author

    When I remove the widget via code and add it again, it has the new content.

  2. Skyost commented on Feb 17, 2020

    @Skyost
    Owner

    I think it's because the state is creating a copy of events (which allows to reorder them and to place them in the stack).

    This should be managed in didUpdateWidget. Will take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions