Repository navigation
platformViewRegistry.registerViewFactory func is missing in import dart.ui #41563
Description
Activity
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!
Reacted by knutsonchris, Javier Garcia, Enzo Conty, Suresh, Pedro Massango, Anipy, wahyu-handayani, Yusuke Hakamaya and Abhinav M KulkarniReacted by carman247, Javier Garcia and hussamDana92For Flutter Web I recommend to use the master channel.
Could you please add the output of flutter doctor - v here- addeda: buildBuilding flutter applications with the toolBuilding flutter applications with the toola: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkplatform-webWeb applications specificallyWeb applications specifically
on Sep 29, 2019 For Flutter Web I recommend to use the master channel.
Could you please add the output of flutter doctor - v hereE:\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>
Do you still have the problem?
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>
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!
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
@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 thingsFacing the same issue now and it is a real show-breaker unfortunately :/ Would be great if this could be fixed soooon... Thanks :)
Reacted by GeneIt 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;Reacted by chunhunghan, Veli Bacik, Dan, Mariano Zorrilla, Gyuri Majercsik, papirovdavid, Ivan Pompa-García, Joe Muller, Peter Aleksander Bizjak, SooYoung Kim and 1 moreReacted by Marianne Abi Kanaan and RoyalNewScoolCodeReacted by RoyalNewScoolCode54 remaining items
How can you make use of the shim?
@RafiqCR7 you import
uifrom the shim, instead of directly. See this: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;thanks ..this help me a lot
Reacted by David IglesiasA 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!
Reacted by aytunc and Tyler Dunn- addedP1High-priority issues at the top of the work listHigh-priority issues at the top of the work listand removedP3Issues that are less important to the Flutter projectIssues that are less important to the Flutter project
on May 19, 2023 - added a commit that references this issue
on May 23, 2023 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!
Reacted by David IglesiasThis 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 -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Jun 6, 2023
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.
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