mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Implement PlatformDispatcher.displays on web (flutter/engine#42297)
I missed this before.
This commit is contained in:
parent
57fb0c0135
commit
45c1fe4348
@ -73,6 +73,24 @@ class HighContrastSupport {
|
||||
}
|
||||
}
|
||||
|
||||
class EngineFlutterDisplay extends ui.Display {
|
||||
EngineFlutterDisplay({
|
||||
required this.id,
|
||||
required this.devicePixelRatio,
|
||||
required this.size,
|
||||
required this.refreshRate,
|
||||
});
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final double devicePixelRatio;
|
||||
@override
|
||||
final ui.Size size;
|
||||
@override
|
||||
final double refreshRate;
|
||||
}
|
||||
|
||||
/// Platform event dispatcher.
|
||||
///
|
||||
/// This is the central entry point for platform messages and configuration
|
||||
@ -135,7 +153,14 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
|
||||
}
|
||||
|
||||
@override
|
||||
Iterable<ui.Display> get displays => <ui.Display>[];
|
||||
Iterable<ui.Display> get displays => <ui.Display>[
|
||||
EngineFlutterDisplay(
|
||||
id: 0,
|
||||
size: ui.Size(domWindow.screen?.width ?? 0, domWindow.screen?.height ?? 0),
|
||||
devicePixelRatio: domWindow.devicePixelRatio,
|
||||
refreshRate: 60,
|
||||
)
|
||||
];
|
||||
|
||||
/// The current list of windows.
|
||||
@override
|
||||
|
||||
@ -29,24 +29,6 @@ const bool debugPrintPlatformMessages = false;
|
||||
/// The view ID for the implicit flutter view provided by the platform.
|
||||
const int kImplicitViewId = 0;
|
||||
|
||||
class EngineFlutterDisplay extends ui.Display {
|
||||
EngineFlutterDisplay({
|
||||
required this.id,
|
||||
required this.devicePixelRatio,
|
||||
required this.size,
|
||||
required this.refreshRate,
|
||||
});
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
final double devicePixelRatio;
|
||||
@override
|
||||
final ui.Size size;
|
||||
@override
|
||||
final double refreshRate;
|
||||
}
|
||||
|
||||
/// The Web implementation of [ui.SingletonFlutterWindow].
|
||||
class EngineFlutterWindow extends ui.SingletonFlutterWindow {
|
||||
EngineFlutterWindow(this.viewId, this.platformDispatcher) {
|
||||
@ -66,12 +48,7 @@ class EngineFlutterWindow extends ui.SingletonFlutterWindow {
|
||||
|
||||
@override
|
||||
ui.Display get display {
|
||||
return EngineFlutterDisplay(
|
||||
id: 0,
|
||||
size: ui.Size(domWindow.screen?.width ?? 0, domWindow.screen?.height ?? 0),
|
||||
devicePixelRatio: domWindow.devicePixelRatio,
|
||||
refreshRate: 60,
|
||||
);
|
||||
return ui.PlatformDispatcher.instance.displays.first;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -18,6 +18,10 @@ void testMain() {
|
||||
ensureFlutterViewEmbedderInitialized();
|
||||
|
||||
group('PlatformDispatcher', () {
|
||||
test('reports at least one display', () {
|
||||
expect(ui.PlatformDispatcher.instance.displays.length, greaterThan(0));
|
||||
});
|
||||
|
||||
test('high contrast in accessibilityFeatures has the correct value', () {
|
||||
final MockHighContrastSupport mockHighContrast =
|
||||
MockHighContrastSupport();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user