Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6b54c26

Browse files
committed
fix batch 3
1 parent 7a62f67 commit 6b54c26

17 files changed

+60
-41
lines changed

lib/web_ui/lib/src/engine/platform_dispatcher.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
461461
case 'flutter/mousecursor':
462462
const MethodCodec codec = StandardMethodCodec();
463463
final MethodCall decoded = codec.decodeMethodCall(data);
464-
final Map<String, dynamic> arguments = decoded.arguments as Map<String, dynamic>;
464+
final Map<dynamic, dynamic> arguments = decoded.arguments as Map<dynamic, dynamic>;
465465
switch (decoded.method) {
466466
case 'activateSystemCursor':
467467
MouseCursor.instance!.activateSystemCursor(arguments.tryString('kind'));

lib/web_ui/lib/src/engine/text/paragraph.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ class DomParagraphBuilder implements ui.ParagraphBuilder {
13721372
// entirely. Occasionally there will be one [pushStyle], which causes this
13731373
// loop to run once then move on to aggregating text.
13741374
while (i < _ops.length && _ops[i] is EngineTextStyle) {
1375-
final EngineTextStyle style = _ops[i];
1375+
final EngineTextStyle style = _ops[i] as EngineTextStyle;
13761376
if (style.color != null) {
13771377
color = style.color!;
13781378
}
@@ -1554,8 +1554,8 @@ class DomParagraphBuilder implements ui.ParagraphBuilder {
15541554

15551555
/// Builds a [Paragraph] as rich text.
15561556
EngineParagraph _buildRichText() {
1557-
final List<dynamic> elementStack = <dynamic>[];
1558-
dynamic currentElement() =>
1557+
final List<html.Element> elementStack = <html.Element>[];
1558+
html.Element currentElement() =>
15591559
elementStack.isNotEmpty ? elementStack.last : _paragraphElement;
15601560

15611561
for (int i = 0; i < _ops.length; i++) {

lib/web_ui/lib/src/engine/window.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import 'navigation/url_strategy.dart';
2121
import 'platform_dispatcher.dart';
2222
import 'services.dart';
2323
import 'test_embedding.dart';
24+
import 'util.dart';
2425

2526
typedef _HandleMessageCallBack = Future<bool> Function();
2627

@@ -152,7 +153,7 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
152153
Future<bool> handleNavigationMessage(ByteData? data) async {
153154
return _waitInTheLine(() async {
154155
final MethodCall decoded = const JSONMethodCodec().decodeMethodCall(data);
155-
final Map<String, dynamic>? arguments = decoded.arguments;
156+
final Map<String, dynamic>? arguments = decoded.arguments as Map<String, dynamic>?;
156157
switch (decoded.method) {
157158
case 'selectMultiEntryHistory':
158159
await _useMultiEntryBrowserHistory();
@@ -164,14 +165,14 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
164165
case 'routeUpdated': // deprecated
165166
assert(arguments != null);
166167
await _useSingleEntryBrowserHistory();
167-
browserHistory.setRouteName(arguments!['routeName']);
168+
browserHistory.setRouteName(arguments!.tryString('routeName'));
168169
return true;
169170
case 'routeInformationUpdated':
170171
assert(arguments != null);
171172
browserHistory.setRouteName(
172-
arguments!['location'],
173-
state: arguments['state'],
174-
replace: arguments['replace'] ?? false,
173+
arguments!.tryString('location'),
174+
state: arguments.tryString('state'),
175+
replace: arguments.tryBool('replace') ?? false,
175176
);
176177
return true;
177178
}

lib/web_ui/test/clipboard_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Future<void> testMain() async {
4040
const MethodCodec codec = JSONMethodCodec();
4141
final Completer<bool> completer = Completer<bool>();
4242
void callback(ByteData? data) {
43-
completer.complete(codec.decodeEnvelope(data!));
43+
completer.complete(codec.decodeEnvelope(data!) as bool);
4444
}
4545

4646
clipboardMessageHandler.setDataMethodCall(
@@ -78,7 +78,7 @@ Future<void> testMain() async {
7878
const MethodCodec codec = JSONMethodCodec();
7979
final Completer<Map<String, dynamic>> completer = Completer<Map<String, dynamic>>();
8080
void callback(ByteData? data) {
81-
completer.complete(codec.decodeEnvelope(data!));
81+
completer.complete(codec.decodeEnvelope(data!) as Map<String, dynamic>);
8282
}
8383

8484
clipboardMessageHandler.getDataMethodCall(callback);

lib/web_ui/test/engine/pointer_binding_test.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,7 +2325,7 @@ mixin _ButtonedEventMixin on _BasicEventContext {
23252325
required double? deltaX,
23262326
required double? deltaY,
23272327
}) {
2328-
final Function jsWheelEvent = js_util.getProperty(html.window, 'WheelEvent');
2328+
final Function jsWheelEvent = js_util.getProperty(html.window, 'WheelEvent') as Function;
23292329
final List<dynamic> eventArgs = <dynamic>[
23302330
'wheel',
23312331
<String, dynamic>{
@@ -2336,7 +2336,10 @@ mixin _ButtonedEventMixin on _BasicEventContext {
23362336
'deltaY': deltaY,
23372337
}
23382338
];
2339-
return js_util.callConstructor(jsWheelEvent, js_util.jsify(eventArgs));
2339+
return js_util.callConstructor(
2340+
jsWheelEvent,
2341+
js_util.jsify(eventArgs) as List<Object?>,
2342+
) as html.Event;
23402343
}
23412344
}
23422345

@@ -2550,7 +2553,7 @@ class _MouseEventContext extends _BasicEventContext
25502553
double? clientY,
25512554
}) {
25522555
final Function jsMouseEvent =
2553-
js_util.getProperty(html.window, 'MouseEvent');
2556+
js_util.getProperty(html.window, 'MouseEvent') as Function;
25542557
final List<dynamic> eventArgs = <dynamic>[
25552558
type,
25562559
<String, dynamic>{
@@ -2560,7 +2563,10 @@ class _MouseEventContext extends _BasicEventContext
25602563
'clientY': clientY,
25612564
}
25622565
];
2563-
return js_util.callConstructor(jsMouseEvent, js_util.jsify(eventArgs));
2566+
return js_util.callConstructor(
2567+
jsMouseEvent,
2568+
js_util.jsify(eventArgs) as List<Object?>,
2569+
) as html.MouseEvent;
25642570
}
25652571
}
25662572

lib/web_ui/test/engine/profiler_test.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ void _profilerTests() {
7777
expect(data, isEmpty);
7878

7979
// Not even a callback.
80+
jsOnBenchmark('string');
8081
expect(
81-
() => jsOnBenchmark('string'),
82+
() => Profiler.instance.benchmark('foo', 123),
8283
throwsA(isA<TypeError>()),
8384
);
8485
});
@@ -159,5 +160,11 @@ class BenchmarkDatapoint {
159160
}
160161

161162
void jsOnBenchmark(dynamic listener) {
162-
js_util.setProperty(html.window, '_flutter_internal_on_benchmark', listener != null ? js.allowInterop(listener) : null);
163+
js_util.setProperty(
164+
html.window,
165+
'_flutter_internal_on_benchmark',
166+
listener is Function
167+
? js.allowInterop(listener)
168+
: listener,
169+
);
163170
}

lib/web_ui/test/engine/surface/scene_builder_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,6 @@ HtmlImage createTestImage({int width = 100, int height = 50}) {
918918
ctx.fillRect(66, 0, 33, 50);
919919
ctx.fill();
920920
final html.ImageElement imageElement = html.ImageElement();
921-
imageElement.src = js_util.callMethod(canvas, 'toDataURL', <dynamic>[]);
921+
imageElement.src = js_util.callMethod(canvas, 'toDataURL', <dynamic>[]) as String;
922922
return HtmlImage(imageElement, width, height);
923923
}

lib/web_ui/test/html/canvas_clip_path_golden_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,6 @@ engine.HtmlImage createTestImage({int width = 200, int height = 150}) {
140140
ctx.fillRect(2 * width / 3, 0, width / 3, height);
141141
ctx.fill();
142142
final html.ImageElement imageElement = html.ImageElement();
143-
imageElement.src = js_util.callMethod(canvas, 'toDataURL', <dynamic>[]);
143+
imageElement.src = js_util.callMethod(canvas, 'toDataURL', <dynamic>[]) as String;
144144
return engine.HtmlImage(imageElement, width, height);
145145
}

lib/web_ui/test/html/compositing/canvas_blend_golden_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,6 @@ HtmlImage createTestImage() {
120120
ctx.fillRect(66, 0, 33, 50);
121121
ctx.fill();
122122
final html.ImageElement imageElement = html.ImageElement();
123-
imageElement.src = js_util.callMethod(canvas, 'toDataURL', <dynamic>[]);
123+
imageElement.src = js_util.callMethod(canvas, 'toDataURL', <dynamic>[]) as String;
124124
return HtmlImage(imageElement, width, height);
125125
}

lib/web_ui/test/html/compositing/color_filter_golden_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,6 @@ HtmlImage createTestImage({int width = 200, int height = 150}) {
189189
ctx.fillRect(2 * width / 3, 0, width / 3, height);
190190
ctx.fill();
191191
final html.ImageElement imageElement = html.ImageElement();
192-
imageElement.src = js_util.callMethod(canvas, 'toDataURL', <dynamic>[]);
192+
imageElement.src = js_util.callMethod(canvas, 'toDataURL', <dynamic>[]) as String;
193193
return HtmlImage(imageElement, width, height);
194194
}

0 commit comments

Comments
 (0)