Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zengfr opened this issue Sep 29, 2019 · 13 comments
Open

Comments

@zengfr
Copy link

@zengfr zengfr commented Sep 29, 2019

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

@GaspardMerten

This comment has been minimized.

Copy link

@GaspardMerten GaspardMerten commented Sep 29, 2019

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!

@escamoteur

This comment has been minimized.

Copy link
Contributor

@escamoteur escamoteur commented Sep 29, 2019

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

@zengfr

This comment has been minimized.

Copy link
Author

@zengfr zengfr commented Sep 29, 2019

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>

@escamoteur

This comment has been minimized.

Copy link
Contributor

@escamoteur escamoteur commented Sep 29, 2019

Do you still have the problem?

@zengfr

This comment has been minimized.

Copy link
Author

@zengfr zengfr commented Sep 29, 2019

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>

@Abhilash-Chandran

This comment has been minimized.

Copy link

@Abhilash-Chandran Abhilash-Chandran commented Sep 30, 2019

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!

@rostopira

This comment has been minimized.

Copy link
Contributor

@rostopira rostopira commented Oct 4, 2019

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

@escamoteur

This comment has been minimized.

Copy link
Contributor

@escamoteur escamoteur commented Oct 4, 2019

@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

@jan-pavlovsky

This comment has been minimized.

Copy link

@jan-pavlovsky jan-pavlovsky commented Oct 30, 2019

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

@Fox32

This comment has been minimized.

Copy link

@Fox32 Fox32 commented Oct 30, 2019

As it compiles and is only an analyser issue, you can ignore it for just that line as a workaround:

    // ignore: undefined_prefixed_name
    ui.platformViewRegistry
        .registerViewFactory(...);
@muhleder

This comment has been minimized.

Copy link

@muhleder muhleder commented Oct 30, 2019

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;
@venshine

This comment has been minimized.

Copy link

@venshine venshine commented Nov 1, 2019

As it compiles and is only an analyser issue, you can ignore it for just that line as a workaround:

    // ignore: undefined_prefixed_name
    ui.platformViewRegistry
        .registerViewFactory(...);

Well, It's good for me.

@carman247

This comment has been minimized.

Copy link

@carman247 carman247 commented Feb 19, 2020

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!

Thank you! This had me so confused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

You can’t perform that action at this time.