0

I have the following streambuilder below. If I put the GestureDetector on the Row widget (as indicated below) it receives the gesture. However, when I put it as shown, it does not. My current theory is that it is due to the List.generation there, however, I guess it could be because there are other widgets above it? It's in a Stack widget...although, if that's the case, why would the GestureDetector work on the Row widget?)

return StreamBuilder<List<List<Event>>>(
        stream: widget.controller.stream.map(_filter),
        initialData: Provider.of<CalendarData>(context).dayEvents,
        builder: (context, snapshot) {
          return Row(
            //GESTUREDETECTOR WORKS HERE
            children: List.generate(8, (col) {
              if (col == 0) {
                return Expanded(
                  child: GestureDetector(
                    behavior: HitTestBehavior.translucent,
                    onTap: () {
                      print('tapped: beer'); //<-- col
                    },
                    onScaleStart: (scaleDetails) => setState(() {
                      print('previousNumOfDays:$previousNumOfDays');
                      print('numberOfDays:$numberOfDays');
                      // dayIndexScaleCenter = col;
                      print('dayIndexScaleCenter: $dayIndexScaleCenter');
                      previousNumOfDays = numberOfDays;
                    }),
                    onScaleUpdate: (ScaleUpdateDetails scaleDetails) {
                      setState(() {
                        int newNumberOfDays =
                            (previousNumOfDays / scaleDetails.scale).round();
                        print('previousNumOfDays:$previousNumOfDays');
                        print('numberOfDays:$numberOfDays');
                        print('newNumberOfDays:$newNumberOfDays');
                        if (newNumberOfDays <= 14 && newNumberOfDays > 1) {
                          numberOfDays = newNumberOfDays;
                        }
                      });
                    },
                    child: Column(
                      children: List.generate(
                        hours.length,
                        (row) => Container(
                          height: Provider.of<CalendarData>(context).rowHeight,
                          decoration: BoxDecoration(
                            color: ColorDefs.colorTimeBackground,
                            border: Border(
                              top: BorderSide(
                                  width: 1.0,
                                  color: ColorDefs.colorCalendarHeader),
                            ),
                          ),
                          child: Center(
                            child: AutoSizeText(hours[row],
                                maxLines: 1,
                                group: timeAutoGroup,
                                minFontSize: 5,
                                style: ColorDefs.textSubtitle2),
                          ),
                        ),
                      ),
                    ),
                  ),
                );
              }
William Terrill
  • 3,484
  • 4
  • 31
  • 41
  • Have you tried ```HitTestBehavior.opaque``` ? – Abbas.M Apr 17 '20 at 17:49
  • the .opaque didn't work. I put HitTestBehavior.translucent on all of the other GestureDetectors on the page, and it worked. I guess something was absorbing the gesture after all... although I'm still uncertain why "Row" worked. – William Terrill Apr 17 '20 at 18:24

0 Answers0