Skip to content

Web-only pieces of dart:ui cause analysis errors #52899

@srawlins

Description

@srawlins

There are some memebers in the web-only "version" of dart:ui that are not found in the mobile version of dart:ui:

  • webOnlyInstantiateImageCodecFromUrl
  • webOnlySetPluginHandler
  • debugEmulateFlutterTesterEnvironment

These cause the following static analysis errors:

  error: The function 'webOnlyInstantiateImageCodecFromUrl' isn't defined - packages/flutter/lib/src/painting/_network_image_web.dart:64:15 - undefined_function
  error: The function 'webOnlySetPluginHandler' isn't defined - packages/flutter_web_plugins/lib/src/plugin_registry.dart:29:8 - undefined_function
  error: The name 'debugEmulateFlutterTesterEnvironment' is being referenced through the prefix 'ui', but it isn't defined in any of the libraries imported using that prefix - packages/flutter_web_plugins/test/plugin_event_channel_test.dart:16:6 - undefined_prefixed_name
  error: The name 'debugEmulateFlutterTesterEnvironment' is being referenced through the prefix 'ui', but it isn't defined in any of the libraries imported using that prefix - packages/flutter_web_plugins/test/plugin_registry_test.dart:33:6 • undefined_prefixed_name

To satisfy CI, these errors are ignored inline, e.g.

ui.debugEmulateFlutterTesterEnvironment = false; // ignore: undefined_prefixed_name

The Dart Analyzer will stop allowing issues with severity error to be ignore (see dart-lang/sdk#27218).

To me it seems that, aside from static analysis, this is awkward code that exists in one version of a library but not another. I spoke to @yjbanov at length about this and we thought of a few solutions:

  1. Define these members in the mobile version of dart:ui, and declare them to throw UnsupportedError, and don't document them.
  2. Define these members in a new library, something like dart:web_ui.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkdependency: dartDart team may need to help usframeworkflutter/packages/flutter repository. See also f: labels.platform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions