Auto focus not working in iOS using html editor enhanced package in flutter

I’m using the html_editor_enhanced package in my Flutter app to provide a rich text editor. I’m trying to programmatically focus the editor (auto-focus) when a screen opens. This works fine on Android, but auto focus doesn’t work on iOS.


Steps to Reproduce:

  1. Add html_editor_enhanced to your project.
  2. Create an editor instance inside a screen.
  3. Call controller.focus() inside initState() or afterFirstLayout.
  4. Run the app on iOS.

Expected Behavior:

Editor should gain focus automatically, and the keyboard should open when the screen loads.


Actual Behavior (iOS):

Editor does not gain focus automatically. The keyboard doesn’t show up. User has to manually tap inside the editor to begin typing.


What I’ve Tried:

  • Called controller.focus() after a delay.
  • Wrapped it in WidgetsBinding.instance.addPostFrameCallback.
  • Tried using JavaScript injection (document.getElementsByClassName("note-editable")[0].focus();) via controller.evaluateJavascript.
  • Verified it works on Android but fails silently on iOS.