Skip to content

Commit 3313d5a

Browse files
authored
Merge pull request Sub6Resources#657 from tneotia/misc/dart-ui-shim
Add shim for dart:ui (increase Pub score)
2 parents c15d499 + b643264 commit 3313d5a

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

lib/shims/dart_ui.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2019 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
/// This file shims dart:ui in web-only scenarios, getting rid of the need to
6+
/// suppress analyzer warnings.
7+
8+
// TODO: flutter/flutter#55000 Remove this file once web-only dart:ui APIs
9+
// are exposed from a dedicated place.
10+
export 'dart_ui_fake.dart' if (dart.library.html) 'dart_ui_real.dart';

lib/shims/dart_ui_fake.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2019 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Fake interface for the logic that this package needs from (web-only) dart:ui.
6+
// This is conditionally exported so the analyzer sees these methods as available.
7+
8+
/// Shim for web_ui engine.PlatformViewRegistry
9+
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/ui.dart#L62
10+
// ignore: camel_case_types
11+
class platformViewRegistry {
12+
/// Shim for registerViewFactory
13+
/// https://github.com/flutter/engine/blob/master/lib/web_ui/lib/ui.dart#L72
14+
static void registerViewFactory(
15+
String viewTypeId, dynamic Function(int viewId) viewFactory) {}
16+
}
17+
18+
/// Signature of callbacks that have no arguments and return no data.
19+
typedef VoidCallback = void Function();

lib/shims/dart_ui_real.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright 2019 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
export 'dart:ui';

lib/src/widgets/iframe_web.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_html/html_parser.dart';
3+
import 'package:flutter_html/shims/dart_ui.dart' as ui;
34
import 'package:flutter_html/src/replaced_element.dart';
45
import 'package:flutter_html/src/utils.dart';
56
import 'package:flutter_html/style.dart';
67
import 'package:webview_flutter/webview_flutter.dart';
78
import 'package:html/dom.dart' as dom;
89
// ignore: avoid_web_libraries_in_flutter
910
import 'dart:html' as html;
10-
import 'dart:ui' as ui;
1111

1212
/// [IframeContentElement is a [ReplacedElement] with web content.
1313
class IframeContentElement extends ReplacedElement {

0 commit comments

Comments
 (0)