srtraj / dropdown_textfield

custom dropdown
MIT License
9 stars 49 forks source link

setState() called after dispose() #64

Open Abdulvaliy opened 2 months ago

Abdulvaliy commented 2 months ago

I face the issue several times after using the package.

Screen Shot 2024-08-05 at 21 13 05

I think, in dropdown_search.dart file, at 375 line it must be checked if context is mounted before updating state (which is in "didChange" callback)

if (state.value != getSelectedItem) {
    WidgetsBinding.instance.addPostFrameCallback((_) {
        if (!context.mounted) return; // TODO (maybe) add this line of code
            state.didChange(getSelectedItem);
      });
}

flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.22.3, on macOS 12.7.1 21G920 darwin-arm64 (Rosetta), locale en-UZ) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [!] Xcode - develop for iOS and macOS (Xcode 14.2) ! Flutter recommends a minimum Xcode version of 15. Download the latest version or update via the Mac App Store. [✓] Chrome - develop for the web [✓] Android Studio (version 2023.2) [✓] Connected device (4 available)
[✓] Network resources