[web] ui.platformViewRegistry => ui_web.platformViewRegistry (#127493)
Now that `platformViewRegistry` is [exposed](https://github.com/flutter/engine/pull/41877) through `dart:ui_web`, we can do some cleanup here. Part of https://github.com/flutter/flutter/issues/126831
This commit is contained in:
@@ -3,11 +3,10 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'web/platform_views/web.dart';
|
||||
|
||||
class DrawPointsPage extends StatefulWidget {
|
||||
const DrawPointsPage({super.key});
|
||||
|
||||
|
||||
@@ -4,19 +4,16 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:html' as html;
|
||||
import 'dart:ui_web' as ui_web;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// TODO(mdebbar): flutter/flutter#55000 Remove this conditional import once
|
||||
// web-only dart:ui_web APIs are exposed from a dedicated place.
|
||||
import 'platform_views/non_web.dart'
|
||||
if (dart.library.html) 'platform_views/web.dart';
|
||||
import 'recorder.dart';
|
||||
|
||||
const String benchmarkViewType = 'benchmark_element';
|
||||
|
||||
void _registerFactory() {
|
||||
platformViewRegistry.registerViewFactory(benchmarkViewType, (int viewId) {
|
||||
ui_web.platformViewRegistry.registerViewFactory(benchmarkViewType, (int viewId) {
|
||||
final html.Element htmlElement = html.DivElement();
|
||||
htmlElement.id = '${benchmarkViewType}_$viewId';
|
||||
htmlElement.innerText = 'Google';
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
// ignore: avoid_classes_with_only_static_members
|
||||
/// Shim for web_ui engine.PlatformViewRegistry
|
||||
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/ui.dart#L62
|
||||
// ignore: camel_case_types
|
||||
class platformViewRegistry {
|
||||
/// Shim for registerViewFactory
|
||||
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/ui.dart#L72
|
||||
static void registerViewFactory(
|
||||
String viewTypeId, dynamic Function(int viewId) viewFactory,
|
||||
{bool isVisible = true}) {}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
// Copyright 2014 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.
|
||||
|
||||
export 'dart:ui';
|
||||
@@ -3,8 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:html' as html;
|
||||
// platformViewRegistry is exposed in the web version
|
||||
import 'dart:ui' as ui show platformViewRegistry; // ignore: undefined_shown_name
|
||||
import 'dart:ui_web' as ui_web;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -37,8 +36,7 @@ void main() {
|
||||
int viewInstanceCount = 0;
|
||||
|
||||
platformViewsRegistry.getNextPlatformViewId();
|
||||
// ignore: undefined_prefixed_name, avoid_dynamic_calls
|
||||
ui.platformViewRegistry.registerViewFactory('MyView', (int viewId) {
|
||||
ui_web.platformViewRegistry.registerViewFactory('MyView', (int viewId) {
|
||||
viewInstanceCount += 1;
|
||||
return html.DivElement();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user