Skip to content

[BUG] Export conflicts between dart:ui and dart:ui_web causing web build failures #598

@VEMUC002

Description

@VEMUC002

Description

The package fails to compile for Flutter web builds due to export conflicts between dart:ui and dart:ui_web. This issue occurs because both libraries are exported unconditionally in lib/utils/shims/dart_ui_real.dart, which causes namespace collisions as Flutter has migrated web-specific APIs from dart:ui to dart:ui_web.

Environment

  • Package version: html_editor_enhanced: 2.7.1
  • Flutter version: 3.35.3 (and likely affects other recent versions)
  • Dart SDK: >=3.7.0
  • Platform: Web (Flutter Web)
  • Build environment: Both local and CI/CD (GitHub Actions)

Error Messages

'debugEmulateFlutterTesterEnvironment' is exported from both 'dart:ui' and 'dart:ui_web'.
'platformViewRegistry' is exported from both 'dart:ui' and 'dart:ui_web'.

Additional Error

There's also a secondary issue with deprecated API usage in lib/utils/utils.dart:

Error: The getter 'window' isn't defined for the type '_DropdownButtonState<T>'.
      final Size size = window.physicalSize;
                        ^^^^^^

Steps to Reproduce

  1. Create a Flutter web project
  2. Add html_editor_enhanced: ^2.7.1 as a dependency (directly or transitively via markdown_widgets)
  3. Run flutter build web --release
  4. Observe compilation failure

Root Cause

As of Flutter 3.x (2025-2026), Flutter has deprecated web-specific APIs in dart:ui and moved them to dart:ui_web. The current implementation in lib/utils/shims/dart_ui_real.dart exports both libraries unconditionally:

Current code (lib/utils/shims/dart_ui_real.dart):

export 'dart:ui';
export 'dart:ui_web';

This causes the symbols platformViewRegistry and debugEmulateFlutterTesterEnvironment to be exported from both libraries, creating ambiguity.

Proposed Solution

Fix 1: Update lib/utils/shims/dart_ui_real.dart to explicitly hide conflicting symbols:

// Copyright 2019 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Hide deprecated symbols from dart:ui that are now in dart:ui_web
// This avoids the "exported from both" conflict
export 'dart:ui' hide platformViewRegistry, debugEmulateFlutterTesterEnvironment;
export 'dart:ui_web';

Fix 2: Update lib/utils/utils.dart to use modern Flutter API:

Add import at the top of the file:

import 'dart:ui' as ui;

Replace deprecated window.physicalSize usage (around line 1050):

// Before
final Size size = window.physicalSize;

// After
final Size size = ui.PlatformDispatcher.instance.views.first.physicalSize;

Why This Approach Works

The hide directive explicitly excludes the deprecated symbols from dart:ui, allowing dart:ui_web to provide them. This is the recommended Flutter migration pattern for handling this deprecation and:

  • ✅ Directly addresses the namespace collision
  • ✅ Works consistently across all platforms (web, mobile, desktop)
  • ✅ Future-proof: when Flutter removes these symbols from dart:ui, the hide clause becomes harmless
  • ✅ No conditional compilation needed
  • ✅ Follows Flutter's deprecation migration best practices

Impact

This issue affects all users building Flutter web applications that depend on html_editor_enhanced version 2.7.1 (and likely earlier versions) with Flutter 3.x+. It completely blocks web builds.

Packages known to be affected:

  • markdown_widgets (uses html_editor_enhanced as a transitive dependency)

Workaround

Until a new version is released, users can patch the package locally.

References


Thank you for maintaining this package! I'm happy to submit a PR with these fixes if that would be helpful.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions