Skip to content

platformViewRegistry.registerViewFactory func is missing in import dart.ui  #41563

Description

@zengfr

Upgrading-from-package:flutter_web-to-the-Flutter-SDK in flutter>=1.9
import 'package:flutter_web_ui/ui.dart' as ui change to import 'dart.ui '
ui.platformViewRegistry.registerViewFactory func is missing.

import 'package:flutter_web_ui/ui.dart' as ui;
 ui.platformViewRegistry.registerViewFactory(
        'maphtml',
            (int viewId) => IFrameElement()
          ..allowFullscreen=true
          ..height = '360'
          ..src = 'https://github.com/zengfr?'+_params
          ..style.border = 'none');

https://github.com/flutter/flutter/wiki/Upgrading-from-package:flutter_web-to-the-Flutter-SDK
Update the pubspec.yaml
Change:
dependencies:
flutter_web: any
flutter_web_ui: any
to:
dependencies:
flutter:
sdk: flutter

Activity

  1. GaspardMerten commented on Sep 29, 2019

    @GaspardMerten

    The problem is just that the analyser version of Flutter does not yet support dart:ui or dart:js! So you should be able to build your app and it will work as expected because the version of Flutter that is used to build/run has dart:ui!

  2. escamoteur commented on Sep 29, 2019

    @escamoteur
    Contributor

    For Flutter Web I recommend to use the master channel.
    Could you please add the output of flutter doctor - v here

  3. added
    a: buildBuilding flutter applications with the tool
    a: error messageError messages from the Flutter framework
    platform-webWeb applications specifically
    on Sep 29, 2019
  4. zengfr commented on Sep 29, 2019

    @zengfr
    Author

    For Flutter Web I recommend to use the master channel.
    Could you please add the output of flutter doctor - v here

    E:\javaproject\flutterwebdemo\examples\myweb>flutter doctor - v
    Doctor summary (to see all details, run flutter doctor -v):
    [√] Flutter (Channel master, v1.10.7-pre.70, on Microsoft Windows [Version 10.0.10240], locale zh-CN)
    [√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    [√] Chrome - develop for the web
    [√] Android Studio (version 3.5)
    [√] IntelliJ IDEA Ultimate Edition (version 2019.1)
    [√] Connected device (2 available)

    • No issues found!

    E:\javaproject\flutterwebdemo\examples\myweb>

  5. escamoteur commented on Sep 29, 2019

    @escamoteur
    Contributor

    Do you still have the problem?

  6. zengfr commented on Sep 29, 2019

    @zengfr
    Author

    is use D:\flutter>flutter upgrade Still have problems

    error: The name 'platformViewRegistry' is being referenced through the prefix 'ui', but it isn't defined in any of the libraries imported using that prefix. (undefined_prefixed_name at [myweb] lib\agent\map.dart:12)

    import 'dart:html';
    import 'package:flutter/material.dart';
    import 'dart:ui' as ui;

    class MapPage extends StatefulWidget {
    final String _params;

    MapPage({String params}) : _params = params;

    @OverRide
    State createState() {
    ui.platformViewRegistry.registerViewFactory(
    'maphtml',
    (int viewId) => IFrameElement()

    Flutter 1.10.7-pre.73 • channel master • https://github.com/flutter/flutter.git
    Framework • revision 67b5bdf (16 hours ago) • 2019-09-28 14:24:46 -0700
    Engine • revision 5b952f2
    Tools • Dart 2.6.0 (build 2.6.0-dev.3.0 6ff8d2199d)

    Running flutter doctor...
    Doctor summary (to see all details, run flutter doctor -v):
    [√] Flutter (Channel master, v1.10.7-pre.73, on Microsoft Windows [Version 10.0.10240], locale zh-CN)
    [√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    [√] Chrome - develop for the web
    [√] Android Studio (version 3.5)
    [√] IntelliJ IDEA Ultimate Edition (version 2019.1)
    [√] Connected device (2 available)

    • No issues found!

    D:\flutter>

  7. Abhilash-Chandran commented on Sep 30, 2019

    @Abhilash-Chandran

    Same issue in my case.

    [√] Flutter (Channel master, v1.10.7-pre.79, on Microsoft Windows [Version 10.0.17134.950], locale de-DE)
    • Flutter version 1.10.7-pre.79 at C:\Abhilash\Installs\flutter
    • Framework revision 7e73cd7 (77 minutes ago), 2019-09-30 14:45:30 +0100
    • Engine revision 5b952f2
    • Dart version 2.6.0 (build 2.6.0-dev.3.0 6ff8d2199d)

    [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at C:\Users\xyz\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Users\xyz\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\191.5791312\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

    [√] Chrome - develop for the web
    • Chrome at C:\Users\xyz\AppData\Local\Google\Chrome\Application\chrome.exe

    [√] Android Studio (version 3.4)
    • Android Studio at C:\Users\xyz\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\183.5692245
    • Flutter plugin version 38.2.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

    [√] Android Studio (version 3.5)
    • Android Studio at C:\Users\xyz\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\191.5791312
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

    [√] VS Code (version 1.38.1)
    • VS Code at C:\Users\xyz\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.4.1

    [√] Connected device (2 available)
    • Chrome • chrome • web-javascript • Google Chrome 77.0.3865.90
    • Server • web • web-javascript • Flutter Tools

    • No issues found!

  8. rostopira commented on Oct 4, 2019

    @rostopira
    Contributor

    Why can't we just add empty function with same declaration in ios/android engine to silence this warning? That shouldn't take a week to fix

  9. escamoteur commented on Oct 4, 2019

    @escamoteur
    Contributor

    @rostopira Flutter Web is still in preview. 5 days ago we got this reported. We currently over 5000 open issues so it depends on the priority an issue has how fast it is Fixed.
    You can make a PR to speed up things

  10. added this to the milestone on Oct 4, 2019
  11. jan-pavlovsky commented on Oct 30, 2019

    @jan-pavlovsky

    Facing the same issue now and it is a real show-breaker unfortunately :/ Would be great if this could be fixed soooon... Thanks :)

  12. Fox32 commented on Oct 30, 2019

    @Fox32
  13. muhleder commented on Oct 30, 2019

    @muhleder

    It compiles for web but fails on mobile. I'm using conditional imports as a workaround for that.

    FakeUi.dart

    // ignore: camel_case_types
    class platformViewRegistry {
      static registerViewFactory(String viewId, dynamic cb) {}
    }
    

    RealUi.dart

    import 'dart:ui' as ui;
    
    // ignore: camel_case_types
    class platformViewRegistry {
      static registerViewFactory(String viewId, dynamic cb) {
        // ignore:undefined_prefixed_name
        ui.platformViewRegistry.registerViewFactory(viewId, cb);
      }
    }
    

    and then to use in a widget

    import 'FakeUi.dart' if (dart.library.html) 'RealUi.dart' as ui;
    
  14. 54 remaining items

  15. ditman commented on Jun 29, 2022

    @ditman
    Member
  16. RoyalNewScoolCode commented on Nov 20, 2022

    @RoyalNewScoolCode

    It compiles for web but fails on mobile. I'm using conditional imports as a workaround for that.

    FakeUi.dart

    // ignore: camel_case_types
    class platformViewRegistry {
      static registerViewFactory(String viewId, dynamic cb) {}
    }
    

    RealUi.dart

    import 'dart:ui' as ui;
    
    // ignore: camel_case_types
    class platformViewRegistry {
      static registerViewFactory(String viewId, dynamic cb) {
        // ignore:undefined_prefixed_name
        ui.platformViewRegistry.registerViewFactory(viewId, cb);
      }
    }
    

    and then to use in a widget

    import 'FakeUi.dart' if (dart.library.html) 'RealUi.dart' as ui;
    
  17. RoyalNewScoolCode commented on Nov 20, 2022

    @RoyalNewScoolCode

    thanks ..this help me a lot

  18. ditman commented on May 19, 2023

    @ditman
    Member

    A fix for this is finally coming!! flutter-team-archive/engine#41877 🎉

    The new API will be something like:

    import 'dart:ui_web' as ui_web; // New import for all web-only stuff...
    
    ...
    
    ui_web.platformViewRegistry.registerViewFactory(...); // as usual!
  19. added
    P1High-priority issues at the top of the work list
    and removed
    P3Issues that are less important to the Flutter project
    on May 19, 2023
  20. removed their assignment
    on May 19, 2023
  21. NotTsunami commented on May 23, 2023

    @NotTsunami

    A fix for this is finally coming!! flutter/engine#41877 🎉

    The new API will be something like:

    import 'dart:ui_web' as ui_web; // New import for all web-only stuff...
    
    ...
    
    ui_web.platformViewRegistry.registerViewFactory(...); // as usual!

    This is fantastic. I hope to see it land in the next stable version!

  22. github-actions commented on Jun 6, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  23. locked as resolved and limited conversation to collaborators on Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: buildBuilding flutter applications with the toola: error messageError messages from the Flutter frameworkcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.found in release: 1.22Found to occur in 1.22frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specifically

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions