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

OnTap doesn't work reliably #17

Closed
ghost opened this issue Mar 13, 2020 · 4 comments
Closed

OnTap doesn't work reliably #17

ghost opened this issue Mar 13, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Mar 13, 2020

When using different onTap() on different events, the execution of the method is random.
For example I have 3 different events and let it print 1 (for event 1), 2 (for event 2) or 3 (for event 3), I don't get a print of 1 every time I press it, but a variation of 1 or 2 or 3.

@Skyost Skyost self-assigned this Mar 14, 2020
@Skyost Skyost added the bug Something isn't working label Mar 14, 2020
@Skyost
Copy link
Owner

Skyost commented Mar 14, 2020

Can you please show me your code ?

@ghost
Copy link
Author

ghost commented Mar 14, 2020

  Widget showDay() {
    return Padding(
      padding: const EdgeInsets.only(right: 10.0),
      child: DayView(
        date: DateTime.now(),
        dayBarHeight: 0,
        eventsColumnBackgroundPainter: new EventsColumnBackgroundPainter(
          backgroundColor: Colors.grey[50],
        ),
        hoursColumnBackgroundColor: Colors.grey[50],
        currentTimeRuleColor: Style.primaryColor,
        currentTimeCircleColor: Style.primaryColor,
        events: getTestEvents(),
        hourRowHeight: 95,
        scrollToCurrentTime: false,
        initialHour: getFirstEventStartTime(),
        userZoomable: true,
        inScrollableWidget: true,
      ),
    );
  }
  List<FlutterWeekViewEvent> getTestEvents() {
    List<FlutterWeekViewEvent> eventList = new List<FlutterWeekViewEvent>();
    eventList.add(new FlutterWeekViewEvent(
        title: 'test1',
        padding: EdgeInsets.all(5),
        description: 'Unbestätigter Termin.',
        start: DateTime.now(),
        end: DateTime.now().add(Duration(hours: 1)),
        backgroundColor: Style.secondaryColor,
        onTap: () {
          print("1");
        }));
    eventList.add(new FlutterWeekViewEvent(
        title: 'test2',
        padding: EdgeInsets.all(5),
        description: 'Unbestätigter Termin.',
        start: DateTime.now(),
        end: DateTime.now().add(Duration(hours: 2)),
        backgroundColor: Style.secondaryColor,
        onTap: () {
          print("2");
        }));
    eventList.add(new FlutterWeekViewEvent(
        title: 'test3',
        padding: EdgeInsets.all(5),
        description: 'Unbestätigter Termin.',
        start: DateTime.now(),
        end: DateTime.now().add(Duration(hours: 3)),
        backgroundColor: Style.secondaryColor,
        onTap: () {
          print("3");
        }));
    return eventList;
  }

@ghost
Copy link
Author

ghost commented Mar 14, 2020

I managed to fix the problem. I am using a Provider, which listens for User Auth changes which causes many rebuilds. Somehow the gesture detectors don't get destroyed while rebuilding. Caching the DayView Widget fixes the problem

@ghost ghost closed this as completed Mar 14, 2020
@Skyost
Copy link
Owner

Skyost commented Mar 14, 2020

Cool ! 😉

This issue was closed.
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

1 participant