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

DayView doesn't rebuild when changing content. #14

Closed
kuemme01 opened this issue Feb 17, 2020 · 2 comments
Closed

DayView doesn't rebuild when changing content. #14

kuemme01 opened this issue Feb 17, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@kuemme01
Copy link

kuemme01 commented Feb 17, 2020

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
@kuemme01 kuemme01 added the bug Something isn't working label Feb 17, 2020
@kuemme01
Copy link
Author

kuemme01 commented Feb 17, 2020

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

@Skyost
Copy link
Owner

Skyost commented Feb 17, 2020

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
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants