This method can be called after the build phase, during the layout of the nearest descendant RenderObjectWidget of the gesture detector, to update the list of active gesture recognizers.
The typical use case is Scrollables, which put their viewport in their gesture detector, and then need to know the dimensions of the viewport and the viewport's child to determine whether the gesture detector should be enabled.
Source
void replaceGestureRecognizers(Map<Type, GestureRecognizerFactory> gestures) { assert(() { // TODO kgiesing This assert will trigger if the owner of the current // tree is different from the owner assigned to the renderer instance. // Once elements have a notion of owners this assertion can be written // more clearly. if (!RendererBinding.instance.pipelineOwner.debugDoingLayout) { throw new FlutterError( 'Unexpected call to replaceGestureRecognizers() method of RawGestureDetectorState.\n' 'The replaceGestureRecognizers() method can only be called during the layout phase. ' 'To set the gesture recognizers at other times, trigger a new build using setState() ' 'and provide the new gesture recognizers as constructor arguments to the corresponding ' 'RawGestureDetector or GestureDetector object.' ); } return true; }); _syncAll(gestures); if (!config.excludeFromSemantics) { RenderSemanticsGestureHandler semanticsGestureHandler = context.findRenderObject(); context.visitChildElements((Element element) { _GestureSemantics widget = element.widget; widget._updateHandlers(semanticsGestureHandler, _recognizers); }); } }