Skip to content

TapGestureRecognizer instances are never disposed #28

Open

Description

@developerjamiu

A TapGestureRecognizer is constructed inside build() for every link span and never disposed:

// lib/src/widgets/smart_text.dart:150,161,172,183,194
recognizer: TapGestureRecognizer()..onTap = () => _handleItemSpanTap(...)

The same five sites exist in smart_selectable_text.dart.

Flutter's own TextSpan.recognizer documentation requires disposal. Every rebuild allocates a fresh set and abandons the previous ones, so a scrolling list of smart text leaks steadily.

Fix: build recognizers when the span list resolves, hold them in State, dispose them in dispose(), and rebuild only when the spans change.

Found during the v0.4.0 codebase audit.

Activity

  1. added
    bug
    platform: dart
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugplatform: dart

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions