1// Copyright 2014 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/// @docImport 'package:flutter/material.dart';
6///
7/// @docImport 'binding.dart';
8/// @docImport 'widget_tester.dart';
9library;
10
11import 'dart:ui' hide window;
12
13import 'package:flutter/foundation.dart';
14import 'package:flutter/widgets.dart';
15
16/// Test version of [AccessibilityFeatures] in which specific features may
17/// be set to arbitrary values.
18///
19/// By default, all features are disabled. For an instance where all the
20/// features are enabled, consider the [FakeAccessibilityFeatures.allOn]
21/// constant.
22@immutable
23class FakeAccessibilityFeatures implements AccessibilityFeatures {
24 /// Creates a test instance of [AccessibilityFeatures].
25 ///
26 /// By default, all features are disabled.
27 const FakeAccessibilityFeatures({
28 this.accessibleNavigation = false,
29 this.invertColors = false,
30 this.disableAnimations = false,
31 this.boldText = false,
32 this.reduceMotion = false,
33 this.highContrast = false,
34 this.onOffSwitchLabels = false,
35 });
36
37 /// An instance of [AccessibilityFeatures] where all the features are enabled.
38 static const FakeAccessibilityFeatures allOn = FakeAccessibilityFeatures(
39 accessibleNavigation: true,
40 invertColors: true,
41 disableAnimations: true,
42 boldText: true,
43 reduceMotion: true,
44 highContrast: true,
45 onOffSwitchLabels: true,
46 );
47
48 @override
49 final bool accessibleNavigation;
50
51 @override
52 final bool invertColors;
53
54 @override
55 final bool disableAnimations;
56
57 @override
58 final bool boldText;
59
60 @override
61 final bool reduceMotion;
62
63 @override
64 final bool highContrast;
65
66 @override
67 final bool onOffSwitchLabels;
68
69 @override
70 bool operator ==(Object other) {
71 if (other.runtimeType != runtimeType) {
72 return false;
73 }
74 return other is FakeAccessibilityFeatures &&
75 other.accessibleNavigation == accessibleNavigation &&
76 other.invertColors == invertColors &&
77 other.disableAnimations == disableAnimations &&
78 other.boldText == boldText &&
79 other.reduceMotion == reduceMotion &&
80 other.highContrast == highContrast &&
81 other.onOffSwitchLabels == onOffSwitchLabels;
82 }
83
84 @override
85 int get hashCode {
86 return Object.hash(
87 accessibleNavigation,
88 invertColors,
89 disableAnimations,
90 boldText,
91 reduceMotion,
92 highContrast,
93 onOffSwitchLabels,
94 );
95 }
96
97 /// This gives us some grace time when the dart:ui side adds something to
98 /// [AccessibilityFeatures], and makes things easier when we do rolls to
99 /// give us time to catch up.
100 ///
101 /// If you would like to add to this class, changes must first be made in the
102 /// engine, followed by the framework.
103 @override
104 dynamic noSuchMethod(Invocation invocation) {
105 return null;
106 }
107}
108
109/// Used to fake insets and padding for [TestFlutterView]s.
110///
111/// See also:
112///
113/// * [TestFlutterView.padding], [TestFlutterView.systemGestureInsets],
114/// [TestFlutterView.viewInsets], and [TestFlutterView.viewPadding] for test
115/// properties that make use of [FakeViewPadding].
116@immutable
117class FakeViewPadding implements ViewPadding {
118 /// Instantiates a new [FakeViewPadding] object for faking insets and padding
119 /// during tests.
120 const FakeViewPadding({this.left = 0.0, this.top = 0.0, this.right = 0.0, this.bottom = 0.0});
121
122 FakeViewPadding._wrap(ViewPadding base)
123 : left = base.left,
124 top = base.top,
125 right = base.right,
126 bottom = base.bottom;
127
128 /// A view padding that has zeros for each edge.
129 static const FakeViewPadding zero = FakeViewPadding();
130
131 @override
132 final double left;
133
134 @override
135 final double top;
136
137 @override
138 final double right;
139
140 @override
141 final double bottom;
142}
143
144/// [PlatformDispatcher] that wraps another [PlatformDispatcher] and
145/// allows faking of some properties for testing purposes.
146///
147/// See also:
148///
149/// * [TestFlutterView], which wraps a [FlutterView] for testing and
150/// mocking purposes.
151class TestPlatformDispatcher implements PlatformDispatcher {
152 /// Constructs a [TestPlatformDispatcher] that defers all behavior to the given
153 /// [PlatformDispatcher] unless explicitly overridden for test purposes.
154 TestPlatformDispatcher({required PlatformDispatcher platformDispatcher})
155 : _platformDispatcher = platformDispatcher {
156 _updateViewsAndDisplays();
157 _platformDispatcher.onMetricsChanged = _handleMetricsChanged;
158 _platformDispatcher.onViewFocusChange = _handleViewFocusChanged;
159 }
160
161 /// The [PlatformDispatcher] that is wrapped by this [TestPlatformDispatcher].
162 final PlatformDispatcher _platformDispatcher;
163
164 @override
165 TestFlutterView? get implicitView {
166 return _platformDispatcher.implicitView != null
167 ? _testViews[_platformDispatcher.implicitView!.viewId]!
168 : null;
169 }
170
171 final Map<int, TestFlutterView> _testViews = <int, TestFlutterView>{};
172 final Map<int, TestDisplay> _testDisplays = <int, TestDisplay>{};
173
174 @override
175 VoidCallback? get onMetricsChanged => _platformDispatcher.onMetricsChanged;
176 VoidCallback? _onMetricsChanged;
177 @override
178 set onMetricsChanged(VoidCallback? callback) {
179 _onMetricsChanged = callback;
180 }
181
182 void _handleMetricsChanged() {
183 _updateViewsAndDisplays();
184 _onMetricsChanged?.call();
185 }
186
187 @override
188 ViewFocusChangeCallback? get onViewFocusChange => _platformDispatcher.onViewFocusChange;
189 ViewFocusChangeCallback? _onViewFocusChange;
190 @override
191 set onViewFocusChange(ViewFocusChangeCallback? callback) {
192 _onViewFocusChange = callback;
193 }
194
195 void _handleViewFocusChanged(ViewFocusEvent event) {
196 _updateViewsAndDisplays();
197 _currentlyFocusedViewId = switch (event.state) {
198 ViewFocusState.focused => event.viewId,
199 ViewFocusState.unfocused => null,
200 };
201 _onViewFocusChange?.call(event);
202 }
203
204 /// Returns the list of [ViewFocusEvent]s that have been received by
205 /// [requestViewFocusChange] since the last call to
206 /// [resetFocusedViewTestValues].
207 ///
208 /// Clearing or modifying the returned list will do nothing (it's a copy).
209 /// Call [resetFocusedViewTestValues] to clear.
210 List<ViewFocusEvent> get testFocusEvents => _testFocusEvents.toList();
211 final List<ViewFocusEvent> _testFocusEvents = <ViewFocusEvent>[];
212
213 /// Returns the last view ID to be focused by [onViewFocusChange].
214 /// Returns null if no views are focused.
215 ///
216 /// Can be reset to null with [resetFocusedViewTestValues].
217 int? get currentlyFocusedViewIdTestValue => _currentlyFocusedViewId;
218 int? _currentlyFocusedViewId;
219
220 /// Clears [testFocusEvents] and sets [currentlyFocusedViewIdTestValue] to
221 /// null.
222 void resetFocusedViewTestValues() {
223 if (_currentlyFocusedViewId != null) {
224 // If there is a focused view, then tell everyone who still cares that
225 // it's unfocusing.
226 _platformDispatcher.onViewFocusChange?.call(
227 ViewFocusEvent(
228 viewId: _currentlyFocusedViewId!,
229 state: ViewFocusState.unfocused,
230 direction: ViewFocusDirection.undefined,
231 ),
232 );
233 _currentlyFocusedViewId = null;
234 }
235 _testFocusEvents.clear();
236 }
237
238 @override
239 void requestViewFocusChange({
240 required int viewId,
241 required ViewFocusState state,
242 required ViewFocusDirection direction,
243 }) {
244 _testFocusEvents.add(ViewFocusEvent(viewId: viewId, state: state, direction: direction));
245 _platformDispatcher.requestViewFocusChange(viewId: viewId, state: state, direction: direction);
246 }
247
248 @override
249 Locale get locale => _localeTestValue ?? _platformDispatcher.locale;
250 Locale? _localeTestValue;
251
252 /// Hides the real locale and reports the given [localeTestValue] instead.
253 // ignore: avoid_setters_without_getters
254 set localeTestValue(Locale localeTestValue) {
255 _localeTestValue = localeTestValue;
256 onLocaleChanged?.call();
257 }
258
259 /// Deletes any existing test locale and returns to using the real locale.
260 void clearLocaleTestValue() {
261 _localeTestValue = null;
262 onLocaleChanged?.call();
263 }
264
265 @override
266 List<Locale> get locales => _localesTestValue ?? _platformDispatcher.locales;
267 List<Locale>? _localesTestValue;
268
269 /// Hides the real locales and reports the given [localesTestValue] instead.
270 // ignore: avoid_setters_without_getters
271 set localesTestValue(List<Locale> localesTestValue) {
272 _localesTestValue = localesTestValue;
273 onLocaleChanged?.call();
274 }
275
276 /// Deletes any existing test locales and returns to using the real locales.
277 void clearLocalesTestValue() {
278 _localesTestValue = null;
279 onLocaleChanged?.call();
280 }
281
282 @override
283 VoidCallback? get onLocaleChanged => _platformDispatcher.onLocaleChanged;
284 @override
285 set onLocaleChanged(VoidCallback? callback) {
286 _platformDispatcher.onLocaleChanged = callback;
287 }
288
289 @override
290 String get initialLifecycleState => _initialLifecycleStateTestValue;
291 String _initialLifecycleStateTestValue = '';
292
293 /// Sets a faked initialLifecycleState for testing.
294 // ignore: avoid_setters_without_getters
295 set initialLifecycleStateTestValue(String state) {
296 _initialLifecycleStateTestValue = state;
297 }
298
299 /// Resets [initialLifecycleState] to the default value for the platform.
300 void resetInitialLifecycleState() {
301 _initialLifecycleStateTestValue = '';
302 }
303
304 @override
305 double get textScaleFactor => _textScaleFactorTestValue ?? _platformDispatcher.textScaleFactor;
306 double? _textScaleFactorTestValue;
307
308 /// Hides the real text scale factor and reports the given
309 /// [textScaleFactorTestValue] instead.
310 // ignore: avoid_setters_without_getters
311 set textScaleFactorTestValue(double textScaleFactorTestValue) {
312 _textScaleFactorTestValue = textScaleFactorTestValue;
313 onTextScaleFactorChanged?.call();
314 }
315
316 /// Deletes any existing test text scale factor and returns to using the real
317 /// text scale factor.
318 void clearTextScaleFactorTestValue() {
319 _textScaleFactorTestValue = null;
320 onTextScaleFactorChanged?.call();
321 }
322
323 @override
324 double scaleFontSize(double unscaledFontSize) => textScaleFactor * unscaledFontSize;
325
326 @override
327 Brightness get platformBrightness =>
328 _platformBrightnessTestValue ?? _platformDispatcher.platformBrightness;
329 Brightness? _platformBrightnessTestValue;
330 @override
331 VoidCallback? get onPlatformBrightnessChanged => _platformDispatcher.onPlatformBrightnessChanged;
332 @override
333 set onPlatformBrightnessChanged(VoidCallback? callback) {
334 _platformDispatcher.onPlatformBrightnessChanged = callback;
335 }
336
337 /// Hides the real platform brightness and reports the given
338 /// [platformBrightnessTestValue] instead.
339 // ignore: avoid_setters_without_getters
340 set platformBrightnessTestValue(Brightness platformBrightnessTestValue) {
341 _platformBrightnessTestValue = platformBrightnessTestValue;
342 onPlatformBrightnessChanged?.call();
343 }
344
345 /// Deletes any existing test platform brightness and returns to using the
346 /// real platform brightness.
347 void clearPlatformBrightnessTestValue() {
348 _platformBrightnessTestValue = null;
349 onPlatformBrightnessChanged?.call();
350 }
351
352 @override
353 bool get alwaysUse24HourFormat =>
354 _alwaysUse24HourFormatTestValue ?? _platformDispatcher.alwaysUse24HourFormat;
355 bool? _alwaysUse24HourFormatTestValue;
356
357 /// Hides the real clock format and reports the given
358 /// [alwaysUse24HourFormatTestValue] instead.
359 // ignore: avoid_setters_without_getters
360 set alwaysUse24HourFormatTestValue(bool alwaysUse24HourFormatTestValue) {
361 _alwaysUse24HourFormatTestValue = alwaysUse24HourFormatTestValue;
362 }
363
364 /// Deletes any existing test clock format and returns to using the real clock
365 /// format.
366 void clearAlwaysUse24HourTestValue() {
367 _alwaysUse24HourFormatTestValue = null;
368 }
369
370 @override
371 VoidCallback? get onTextScaleFactorChanged => _platformDispatcher.onTextScaleFactorChanged;
372 @override
373 set onTextScaleFactorChanged(VoidCallback? callback) {
374 _platformDispatcher.onTextScaleFactorChanged = callback;
375 }
376
377 @override
378 bool get nativeSpellCheckServiceDefined =>
379 _nativeSpellCheckServiceDefinedTestValue ??
380 _platformDispatcher.nativeSpellCheckServiceDefined;
381 bool? _nativeSpellCheckServiceDefinedTestValue;
382 // ignore: avoid_setters_without_getters
383 set nativeSpellCheckServiceDefinedTestValue(bool nativeSpellCheckServiceDefinedTestValue) {
384 _nativeSpellCheckServiceDefinedTestValue = nativeSpellCheckServiceDefinedTestValue;
385 }
386
387 /// Deletes existing value that determines whether or not a native spell check
388 /// service is defined and returns to the real value.
389 void clearNativeSpellCheckServiceDefined() {
390 _nativeSpellCheckServiceDefinedTestValue = null;
391 }
392
393 @override
394 bool get supportsShowingSystemContextMenu =>
395 _supportsShowingSystemContextMenu ?? _platformDispatcher.supportsShowingSystemContextMenu;
396 bool? _supportsShowingSystemContextMenu;
397 set supportsShowingSystemContextMenu(bool value) {
398 _supportsShowingSystemContextMenu = value;
399 }
400
401 /// Resets [supportsShowingSystemContextMenu] to the default value.
402 void resetSupportsShowingSystemContextMenu() {
403 _supportsShowingSystemContextMenu = null;
404 }
405
406 @override
407 bool get brieflyShowPassword =>
408 _brieflyShowPasswordTestValue ?? _platformDispatcher.brieflyShowPassword;
409 bool? _brieflyShowPasswordTestValue;
410
411 /// Hides the real [brieflyShowPassword] and reports the given
412 /// `brieflyShowPasswordTestValue` instead.
413 // ignore: avoid_setters_without_getters
414 set brieflyShowPasswordTestValue(bool brieflyShowPasswordTestValue) {
415 _brieflyShowPasswordTestValue = brieflyShowPasswordTestValue;
416 }
417
418 /// Resets [brieflyShowPassword] to the default value for the platform.
419 void resetBrieflyShowPassword() {
420 _brieflyShowPasswordTestValue = null;
421 }
422
423 @override
424 FrameCallback? get onBeginFrame => _platformDispatcher.onBeginFrame;
425 @override
426 set onBeginFrame(FrameCallback? callback) {
427 _platformDispatcher.onBeginFrame = callback;
428 }
429
430 @override
431 VoidCallback? get onDrawFrame => _platformDispatcher.onDrawFrame;
432 @override
433 set onDrawFrame(VoidCallback? callback) {
434 _platformDispatcher.onDrawFrame = callback;
435 }
436
437 @override
438 TimingsCallback? get onReportTimings => _platformDispatcher.onReportTimings;
439 @override
440 set onReportTimings(TimingsCallback? callback) {
441 _platformDispatcher.onReportTimings = callback;
442 }
443
444 @override
445 PointerDataPacketCallback? get onPointerDataPacket => _platformDispatcher.onPointerDataPacket;
446 @override
447 set onPointerDataPacket(PointerDataPacketCallback? callback) {
448 _platformDispatcher.onPointerDataPacket = callback;
449 }
450
451 @override
452 String get defaultRouteName => _defaultRouteNameTestValue ?? _platformDispatcher.defaultRouteName;
453 String? _defaultRouteNameTestValue;
454
455 /// Hides the real default route name and reports the given
456 /// [defaultRouteNameTestValue] instead.
457 // ignore: avoid_setters_without_getters
458 set defaultRouteNameTestValue(String defaultRouteNameTestValue) {
459 _defaultRouteNameTestValue = defaultRouteNameTestValue;
460 }
461
462 /// Deletes any existing test default route name and returns to using the real
463 /// default route name.
464 void clearDefaultRouteNameTestValue() {
465 _defaultRouteNameTestValue = null;
466 }
467
468 @override
469 void scheduleFrame() {
470 _platformDispatcher.scheduleFrame();
471 }
472
473 @override
474 bool get semanticsEnabled => _semanticsEnabledTestValue ?? _platformDispatcher.semanticsEnabled;
475 bool? _semanticsEnabledTestValue;
476
477 /// Hides the real semantics enabled and reports the given
478 /// [semanticsEnabledTestValue] instead.
479 // ignore: avoid_setters_without_getters
480 set semanticsEnabledTestValue(bool semanticsEnabledTestValue) {
481 _semanticsEnabledTestValue = semanticsEnabledTestValue;
482 onSemanticsEnabledChanged?.call();
483 }
484
485 /// Deletes any existing test semantics enabled and returns to using the real
486 /// semantics enabled.
487 void clearSemanticsEnabledTestValue() {
488 _semanticsEnabledTestValue = null;
489 onSemanticsEnabledChanged?.call();
490 }
491
492 @override
493 VoidCallback? get onSemanticsEnabledChanged => _platformDispatcher.onSemanticsEnabledChanged;
494 @override
495 set onSemanticsEnabledChanged(VoidCallback? callback) {
496 _platformDispatcher.onSemanticsEnabledChanged = callback;
497 }
498
499 @override
500 SemanticsActionEventCallback? get onSemanticsActionEvent =>
501 _platformDispatcher.onSemanticsActionEvent;
502 @override
503 set onSemanticsActionEvent(SemanticsActionEventCallback? callback) {
504 _platformDispatcher.onSemanticsActionEvent = callback;
505 }
506
507 @override
508 AccessibilityFeatures get accessibilityFeatures =>
509 _accessibilityFeaturesTestValue ?? _platformDispatcher.accessibilityFeatures;
510 AccessibilityFeatures? _accessibilityFeaturesTestValue;
511
512 /// Hides the real accessibility features and reports the given
513 /// [accessibilityFeaturesTestValue] instead.
514 ///
515 /// Consider using [FakeAccessibilityFeatures] to provide specific
516 /// values for the various accessibility features under test.
517 // ignore: avoid_setters_without_getters
518 set accessibilityFeaturesTestValue(AccessibilityFeatures accessibilityFeaturesTestValue) {
519 _accessibilityFeaturesTestValue = accessibilityFeaturesTestValue;
520 onAccessibilityFeaturesChanged?.call();
521 }
522
523 /// Deletes any existing test accessibility features and returns to using the
524 /// real accessibility features.
525 void clearAccessibilityFeaturesTestValue() {
526 _accessibilityFeaturesTestValue = null;
527 onAccessibilityFeaturesChanged?.call();
528 }
529
530 @override
531 VoidCallback? get onAccessibilityFeaturesChanged =>
532 _platformDispatcher.onAccessibilityFeaturesChanged;
533 @override
534 set onAccessibilityFeaturesChanged(VoidCallback? callback) {
535 _platformDispatcher.onAccessibilityFeaturesChanged = callback;
536 }
537
538 @override
539 void setIsolateDebugName(String name) {
540 _platformDispatcher.setIsolateDebugName(name);
541 }
542
543 @override
544 void sendPlatformMessage(String name, ByteData? data, PlatformMessageResponseCallback? callback) {
545 _platformDispatcher.sendPlatformMessage(name, data, callback);
546 }
547
548 /// Delete any test value properties that have been set on this [TestPlatformDispatcher]
549 /// and return to reporting the real [PlatformDispatcher] values for all
550 /// [PlatformDispatcher] properties.
551 ///
552 /// If desired, clearing of properties can be done on an individual basis,
553 /// e.g., [clearLocaleTestValue].
554 void clearAllTestValues() {
555 clearAccessibilityFeaturesTestValue();
556 clearAlwaysUse24HourTestValue();
557 clearDefaultRouteNameTestValue();
558 clearPlatformBrightnessTestValue();
559 clearLocaleTestValue();
560 clearLocalesTestValue();
561 clearSemanticsEnabledTestValue();
562 clearTextScaleFactorTestValue();
563 clearNativeSpellCheckServiceDefined();
564 resetBrieflyShowPassword();
565 resetSupportsShowingSystemContextMenu();
566 resetInitialLifecycleState();
567 resetSystemFontFamily();
568 }
569
570 @override
571 VoidCallback? get onFrameDataChanged => _platformDispatcher.onFrameDataChanged;
572 @override
573 set onFrameDataChanged(VoidCallback? value) {
574 _platformDispatcher.onFrameDataChanged = value;
575 }
576
577 @override
578 KeyDataCallback? get onKeyData => _platformDispatcher.onKeyData;
579
580 @override
581 set onKeyData(KeyDataCallback? onKeyData) {
582 _platformDispatcher.onKeyData = onKeyData;
583 }
584
585 @override
586 VoidCallback? get onPlatformConfigurationChanged =>
587 _platformDispatcher.onPlatformConfigurationChanged;
588
589 @override
590 set onPlatformConfigurationChanged(VoidCallback? onPlatformConfigurationChanged) {
591 _platformDispatcher.onPlatformConfigurationChanged = onPlatformConfigurationChanged;
592 }
593
594 @override
595 Locale? computePlatformResolvedLocale(List<Locale> supportedLocales) =>
596 _platformDispatcher.computePlatformResolvedLocale(supportedLocales);
597
598 @override
599 ByteData? getPersistentIsolateData() => _platformDispatcher.getPersistentIsolateData();
600
601 @override
602 Iterable<TestFlutterView> get views => _testViews.values;
603
604 @override
605 FlutterView? view({required int id}) => _testViews[id];
606
607 @override
608 Iterable<TestDisplay> get displays => _testDisplays.values;
609
610 void _updateViewsAndDisplays() {
611 final List<Object> extraDisplayKeys = <Object>[..._testDisplays.keys];
612 for (final Display display in _platformDispatcher.displays) {
613 extraDisplayKeys.remove(display.id);
614 if (!_testDisplays.containsKey(display.id)) {
615 _testDisplays[display.id] = TestDisplay(this, display);
616 }
617 }
618 extraDisplayKeys.forEach(_testDisplays.remove);
619
620 final List<Object> extraViewKeys = <Object>[..._testViews.keys];
621 for (final FlutterView view in _platformDispatcher.views) {
622 // TODO(pdblasi-google): Remove this try-catch once the Display API is stable and supported on all platforms
623 late final TestDisplay display;
624 try {
625 final Display realDisplay = view.display;
626 if (_testDisplays.containsKey(realDisplay.id)) {
627 display = _testDisplays[view.display.id]!;
628 } else {
629 display = _UnsupportedDisplay(
630 this,
631 view,
632 'PlatformDispatcher did not contain a Display with id ${realDisplay.id}, '
633 'which was expected by FlutterView ($view)',
634 );
635 }
636 } catch (error) {
637 display = _UnsupportedDisplay(this, view, error);
638 }
639
640 extraViewKeys.remove(view.viewId);
641 if (!_testViews.containsKey(view.viewId)) {
642 _testViews[view.viewId] = TestFlutterView(
643 view: view,
644 platformDispatcher: this,
645 display: display,
646 );
647 }
648 }
649
650 extraViewKeys.forEach(_testViews.remove);
651 }
652
653 @override
654 ErrorCallback? get onError => _platformDispatcher.onError;
655 @override
656 set onError(ErrorCallback? value) {
657 _platformDispatcher.onError;
658 }
659
660 @override
661 VoidCallback? get onSystemFontFamilyChanged => _platformDispatcher.onSystemFontFamilyChanged;
662 @override
663 set onSystemFontFamilyChanged(VoidCallback? value) {
664 _platformDispatcher.onSystemFontFamilyChanged = value;
665 }
666
667 @override
668 FrameData get frameData => _platformDispatcher.frameData;
669
670 @override
671 void registerBackgroundIsolate(RootIsolateToken token) {
672 _platformDispatcher.registerBackgroundIsolate(token);
673 }
674
675 @override
676 void requestDartPerformanceMode(DartPerformanceMode mode) {
677 _platformDispatcher.requestDartPerformanceMode(mode);
678 }
679
680 /// The system font family to use for this test.
681 ///
682 /// Defaults to the value provided by [PlatformDispatcher.systemFontFamily].
683 /// This can only be set in a test environment to emulate different platform
684 /// configurations. A standard [PlatformDispatcher] is not mutable from the
685 /// framework.
686 ///
687 /// Setting this value to `null` will force [systemFontFamily] to return
688 /// `null`. If you want to have the value default to the platform
689 /// [systemFontFamily], use [resetSystemFontFamily].
690 ///
691 /// See also:
692 ///
693 /// * [PlatformDispatcher.systemFontFamily] for the standard implementation
694 /// * [resetSystemFontFamily] to reset this value specifically
695 /// * [clearAllTestValues] to reset all test values for this view
696 @override
697 String? get systemFontFamily {
698 return _forceSystemFontFamilyToBeNull
699 ? null
700 : _systemFontFamily ?? _platformDispatcher.systemFontFamily;
701 }
702
703 String? _systemFontFamily;
704 bool _forceSystemFontFamilyToBeNull = false;
705 set systemFontFamily(String? value) {
706 _systemFontFamily = value;
707 if (value == null) {
708 _forceSystemFontFamilyToBeNull = true;
709 }
710 onSystemFontFamilyChanged?.call();
711 }
712
713 /// Resets [systemFontFamily] to the default for the platform.
714 void resetSystemFontFamily() {
715 _systemFontFamily = null;
716 _forceSystemFontFamilyToBeNull = false;
717 onSystemFontFamilyChanged?.call();
718 }
719
720 @override
721 void updateSemantics(SemanticsUpdate update) {
722 _platformDispatcher.updateSemantics(update);
723 }
724
725 /// This gives us some grace time when the dart:ui side adds something to
726 /// [PlatformDispatcher], and makes things easier when we do rolls to give
727 /// us time to catch up.
728 @override
729 dynamic noSuchMethod(Invocation invocation) {
730 return null;
731 }
732}
733
734/// A [FlutterView] that wraps another [FlutterView] and allows faking of
735/// some properties for testing purposes.
736///
737/// This class should not be instantiated manually, as
738/// it requires a backing [FlutterView] that must be produced from
739/// a [PlatformDispatcher].
740///
741/// See also:
742///
743/// * [WidgetTester.view] which allows for accessing the [TestFlutterView]
744/// for single view applications or widget testing.
745/// * [WidgetTester.viewOf] which allows for accessing the appropriate
746/// [TestFlutterView] in a given situation for multi-view applications.
747/// * [TestPlatformDispatcher], which allows for faking of platform specific
748/// functionality.
749class TestFlutterView implements FlutterView {
750 /// Constructs a [TestFlutterView] that defers all behavior to the given
751 /// [FlutterView] unless explicitly overridden for testing.
752 TestFlutterView({
753 required FlutterView view,
754 required TestPlatformDispatcher platformDispatcher,
755 required TestDisplay display,
756 }) : _view = view,
757 _platformDispatcher = platformDispatcher,
758 _display = display;
759
760 /// The [FlutterView] backing this [TestFlutterView].
761 final FlutterView _view;
762
763 @override
764 TestPlatformDispatcher get platformDispatcher => _platformDispatcher;
765 final TestPlatformDispatcher _platformDispatcher;
766
767 @override
768 TestDisplay get display => _display;
769 final TestDisplay _display;
770
771 @override
772 int get viewId => _view.viewId;
773
774 /// The device pixel ratio to use for this test.
775 ///
776 /// Defaults to the value provided by [FlutterView.devicePixelRatio]. This
777 /// can only be set in a test environment to emulate different view
778 /// configurations. A standard [FlutterView] is not mutable from the framework.
779 ///
780 /// See also:
781 ///
782 /// * [FlutterView.devicePixelRatio] for the standard implementation
783 /// * [TestDisplay.devicePixelRatio] which will stay in sync with this value
784 /// * [resetDevicePixelRatio] to reset this value specifically
785 /// * [reset] to reset all test values for this view
786 @override
787 double get devicePixelRatio => _display._devicePixelRatio ?? _view.devicePixelRatio;
788 set devicePixelRatio(double value) {
789 _display.devicePixelRatio = value;
790 }
791
792 /// Resets [devicePixelRatio] for this test view to the default value for this view.
793 ///
794 /// This will also reset the [devicePixelRatio] for the [TestDisplay]
795 /// that is related to this view.
796 void resetDevicePixelRatio() {
797 _display.resetDevicePixelRatio();
798 }
799
800 /// The display features to use for this test.
801 ///
802 /// Defaults to the value provided by [FlutterView.displayFeatures]. This
803 /// can only be set in a test environment to emulate different view
804 /// configurations. A standard [FlutterView] is not mutable from the framework.
805 ///
806 /// See also:
807 ///
808 /// * [FlutterView.displayFeatures] for the standard implementation
809 /// * [resetDisplayFeatures] to reset this value specifically
810 /// * [reset] to reset all test values for this view
811 @override
812 List<DisplayFeature> get displayFeatures => _displayFeatures ?? _view.displayFeatures;
813 List<DisplayFeature>? _displayFeatures;
814 set displayFeatures(List<DisplayFeature> value) {
815 _displayFeatures = value;
816 platformDispatcher.onMetricsChanged?.call();
817 }
818
819 /// Resets [displayFeatures] to the default values for this view.
820 void resetDisplayFeatures() {
821 _displayFeatures = null;
822 platformDispatcher.onMetricsChanged?.call();
823 }
824
825 /// The padding to use for this test.
826 ///
827 /// Defaults to the value provided by [FlutterView.padding]. This
828 /// can only be set in a test environment to emulate different view
829 /// configurations. A standard [FlutterView] is not mutable from the framework.
830 ///
831 /// See also:
832 ///
833 /// * [FakeViewPadding] which is used to set this value for testing
834 /// * [FlutterView.padding] for the standard implementation.
835 /// * [resetPadding] to reset this value specifically.
836 /// * [reset] to reset all test values for this view.
837 @override
838 FakeViewPadding get padding => _padding ?? FakeViewPadding._wrap(_view.padding);
839 FakeViewPadding? _padding;
840 set padding(FakeViewPadding value) {
841 _padding = value;
842 platformDispatcher.onMetricsChanged?.call();
843 }
844
845 /// Resets [padding] to the default value for this view.
846 void resetPadding() {
847 _padding = null;
848 platformDispatcher.onMetricsChanged?.call();
849 }
850
851 /// The physical size to use for this test.
852 ///
853 /// Defaults to the value provided by [FlutterView.physicalSize]. This
854 /// can only be set in a test environment to emulate different view
855 /// configurations. A standard [FlutterView] is not mutable from the framework.
856 ///
857 /// Setting this value also sets [physicalConstraints] to tight constraints
858 /// based on the given size.
859 ///
860 /// See also:
861 ///
862 /// * [FlutterView.physicalSize] for the standard implementation
863 /// * [resetPhysicalSize] to reset this value specifically
864 /// * [reset] to reset all test values for this view
865 @override
866 Size get physicalSize => _physicalSize ?? _view.physicalSize;
867 Size? _physicalSize;
868 set physicalSize(Size value) {
869 _physicalSize = value;
870 // For backwards compatibility the constraints are set based on the provided size.
871 physicalConstraints = ViewConstraints.tight(value);
872 }
873
874 /// Resets [physicalSize] (and implicitly also the [physicalConstraints]) to
875 /// the default value for this view.
876 void resetPhysicalSize() {
877 _physicalSize = null;
878 resetPhysicalConstraints();
879 }
880
881 /// The physical constraints to use for this test.
882 ///
883 /// Defaults to the value provided by [FlutterView.physicalConstraints]. This
884 /// can only be set in a test environment to emulate different view
885 /// configurations. A standard [FlutterView] is not mutable from the framework.
886 ///
887 /// See also:
888 ///
889 /// * [FlutterView.physicalConstraints] for the standard implementation
890 /// * [physicalConstraints] to reset this value specifically
891 /// * [reset] to reset all test values for this view
892 @override
893 ViewConstraints get physicalConstraints => _physicalConstraints ?? _view.physicalConstraints;
894 ViewConstraints? _physicalConstraints;
895 set physicalConstraints(ViewConstraints value) {
896 _physicalConstraints = value;
897 platformDispatcher.onMetricsChanged?.call();
898 }
899
900 /// Resets [physicalConstraints] to the default value for this view.
901 void resetPhysicalConstraints() {
902 _physicalConstraints = null;
903 platformDispatcher.onMetricsChanged?.call();
904 }
905
906 /// The system gesture insets to use for this test.
907 ///
908 /// Defaults to the value provided by [FlutterView.systemGestureInsets].
909 /// This can only be set in a test environment to emulate different view
910 /// configurations. A standard [FlutterView] is not mutable from the framework.
911 ///
912 /// See also:
913 ///
914 /// * [FakeViewPadding] which is used to set this value for testing
915 /// * [FlutterView.systemGestureInsets] for the standard implementation
916 /// * [resetSystemGestureInsets] to reset this value specifically
917 /// * [reset] to reset all test values for this view
918 @override
919 FakeViewPadding get systemGestureInsets =>
920 _systemGestureInsets ?? FakeViewPadding._wrap(_view.systemGestureInsets);
921 FakeViewPadding? _systemGestureInsets;
922 set systemGestureInsets(FakeViewPadding value) {
923 _systemGestureInsets = value;
924 platformDispatcher.onMetricsChanged?.call();
925 }
926
927 /// Resets [systemGestureInsets] to the default value for this view.
928 void resetSystemGestureInsets() {
929 _systemGestureInsets = null;
930 platformDispatcher.onMetricsChanged?.call();
931 }
932
933 /// The view insets to use for this test.
934 ///
935 /// Defaults to the value provided by [FlutterView.viewInsets]. This
936 /// can only be set in a test environment to emulate different view
937 /// configurations. A standard [FlutterView] is not mutable from the framework.
938 ///
939 /// See also:
940 ///
941 /// * [FakeViewPadding] which is used to set this value for testing
942 /// * [FlutterView.viewInsets] for the standard implementation
943 /// * [resetViewInsets] to reset this value specifically
944 /// * [reset] to reset all test values for this view
945 @override
946 FakeViewPadding get viewInsets => _viewInsets ?? FakeViewPadding._wrap(_view.viewInsets);
947 FakeViewPadding? _viewInsets;
948 set viewInsets(FakeViewPadding value) {
949 _viewInsets = value;
950 platformDispatcher.onMetricsChanged?.call();
951 }
952
953 /// Resets [viewInsets] to the default value for this view.
954 void resetViewInsets() {
955 _viewInsets = null;
956 platformDispatcher.onMetricsChanged?.call();
957 }
958
959 /// The view padding to use for this test.
960 ///
961 /// Defaults to the value provided by [FlutterView.viewPadding]. This
962 /// can only be set in a test environment to emulate different view
963 /// configurations. A standard [FlutterView] is not mutable from the framework.
964 ///
965 /// See also:
966 ///
967 /// * [FakeViewPadding] which is used to set this value for testing
968 /// * [FlutterView.viewPadding] for the standard implementation
969 /// * [resetViewPadding] to reset this value specifically
970 /// * [reset] to reset all test values for this view
971 @override
972 FakeViewPadding get viewPadding => _viewPadding ?? FakeViewPadding._wrap(_view.viewPadding);
973 FakeViewPadding? _viewPadding;
974 set viewPadding(FakeViewPadding value) {
975 _viewPadding = value;
976 platformDispatcher.onMetricsChanged?.call();
977 }
978
979 /// Resets [viewPadding] to the default value for this view.
980 void resetViewPadding() {
981 _viewPadding = null;
982 platformDispatcher.onMetricsChanged?.call();
983 }
984
985 /// The gesture settings to use for this test.
986 ///
987 /// Defaults to the value provided by [FlutterView.gestureSettings]. This
988 /// can only be set in a test environment to emulate different view
989 /// configurations. A standard [FlutterView] is not mutable from the framework.
990 ///
991 /// See also:
992 ///
993 /// * [FlutterView.gestureSettings] for the standard implementation
994 /// * [resetGestureSettings] to reset this value specifically
995 /// * [reset] to reset all test values for this view
996 @override
997 GestureSettings get gestureSettings => _gestureSettings ?? _view.gestureSettings;
998 GestureSettings? _gestureSettings;
999 set gestureSettings(GestureSettings value) {
1000 _gestureSettings = value;
1001 platformDispatcher.onMetricsChanged?.call();
1002 }
1003
1004 /// Resets [gestureSettings] to the default value for this view.
1005 void resetGestureSettings() {
1006 _gestureSettings = null;
1007 platformDispatcher.onMetricsChanged?.call();
1008 }
1009
1010 @override
1011 void render(Scene scene, {Size? size}) {
1012 _view.render(scene, size: size);
1013 }
1014
1015 @override
1016 void updateSemantics(SemanticsUpdate update) {
1017 _view.updateSemantics(update);
1018 }
1019
1020 /// Resets all test values to the defaults for this view.
1021 ///
1022 /// See also:
1023 ///
1024 /// * [resetDevicePixelRatio] to reset [devicePixelRatio] specifically
1025 /// * [resetDisplayFeatures] to reset [displayFeatures] specifically
1026 /// * [resetPadding] to reset [padding] specifically
1027 /// * [resetPhysicalSize] to reset [physicalSize] specifically
1028 /// * [resetSystemGestureInsets] to reset [systemGestureInsets] specifically
1029 /// * [resetViewInsets] to reset [viewInsets] specifically
1030 /// * [resetViewPadding] to reset [viewPadding] specifically
1031 /// * [resetGestureSettings] to reset [gestureSettings] specifically
1032 void reset() {
1033 resetDevicePixelRatio();
1034 resetDisplayFeatures();
1035 resetPadding();
1036 resetPhysicalSize();
1037 // resetPhysicalConstraints is implicitly called by resetPhysicalSize.
1038 resetSystemGestureInsets();
1039 resetViewInsets();
1040 resetViewPadding();
1041 resetGestureSettings();
1042 }
1043
1044 /// This gives us some grace time when the dart:ui side adds something to
1045 /// [FlutterView], and makes things easier when we do rolls to give
1046 /// us time to catch up.
1047 @override
1048 dynamic noSuchMethod(Invocation invocation) {
1049 return null;
1050 }
1051}
1052
1053/// A version of [Display] that can be modified to allow for testing various
1054/// use cases.
1055///
1056/// Updates to the [TestDisplay] will be surfaced through
1057/// [PlatformDispatcher.onMetricsChanged].
1058class TestDisplay implements Display {
1059 /// Creates a new [TestDisplay] backed by the given [Display].
1060 TestDisplay(TestPlatformDispatcher platformDispatcher, Display display)
1061 : _platformDispatcher = platformDispatcher,
1062 _display = display;
1063
1064 final Display _display;
1065 final TestPlatformDispatcher _platformDispatcher;
1066
1067 @override
1068 int get id => _display.id;
1069
1070 /// The device pixel ratio to use for this test.
1071 ///
1072 /// Defaults to the value provided by [Display.devicePixelRatio]. This
1073 /// can only be set in a test environment to emulate different display
1074 /// configurations. A standard [Display] is not mutable from the framework.
1075 ///
1076 /// See also:
1077 ///
1078 /// * [Display.devicePixelRatio] for the standard implementation
1079 /// * [TestFlutterView.devicePixelRatio] which will stay in sync with this value
1080 /// * [resetDevicePixelRatio] to reset this value specifically
1081 /// * [reset] to reset all test values for this display
1082 @override
1083 double get devicePixelRatio => _devicePixelRatio ?? _display.devicePixelRatio;
1084 double? _devicePixelRatio;
1085 set devicePixelRatio(double value) {
1086 _devicePixelRatio = value;
1087 _platformDispatcher.onMetricsChanged?.call();
1088 }
1089
1090 /// Resets [devicePixelRatio] to the default value for this display.
1091 ///
1092 /// This will also reset the [devicePixelRatio] for any [TestFlutterView]s
1093 /// that are related to this display.
1094 void resetDevicePixelRatio() {
1095 _devicePixelRatio = null;
1096 _platformDispatcher.onMetricsChanged?.call();
1097 }
1098
1099 /// The refresh rate to use for this test.
1100 ///
1101 /// Defaults to the value provided by [Display.refreshRate]. This
1102 /// can only be set in a test environment to emulate different display
1103 /// configurations. A standard [Display] is not mutable from the framework.
1104 ///
1105 /// See also:
1106 ///
1107 /// * [Display.refreshRate] for the standard implementation
1108 /// * [resetRefreshRate] to reset this value specifically
1109 /// * [reset] to reset all test values for this display
1110 @override
1111 double get refreshRate => _refreshRate ?? _display.refreshRate;
1112 double? _refreshRate;
1113 set refreshRate(double value) {
1114 _refreshRate = value;
1115 _platformDispatcher.onMetricsChanged?.call();
1116 }
1117
1118 /// Resets [refreshRate] to the default value for this display.
1119 void resetRefreshRate() {
1120 _refreshRate = null;
1121 _platformDispatcher.onMetricsChanged?.call();
1122 }
1123
1124 /// The size of the [Display] to use for this test.
1125 ///
1126 /// Defaults to the value provided by [Display.refreshRate]. This
1127 /// can only be set in a test environment to emulate different display
1128 /// configurations. A standard [Display] is not mutable from the framework.
1129 ///
1130 /// See also:
1131 ///
1132 /// * [Display.refreshRate] for the standard implementation
1133 /// * [resetRefreshRate] to reset this value specifically
1134 /// * [reset] to reset all test values for this display
1135 @override
1136 Size get size => _size ?? _display.size;
1137 Size? _size;
1138 set size(Size value) {
1139 _size = value;
1140 _platformDispatcher.onMetricsChanged?.call();
1141 }
1142
1143 /// Resets [size] to the default value for this display.
1144 void resetSize() {
1145 _size = null;
1146 _platformDispatcher.onMetricsChanged?.call();
1147 }
1148
1149 /// Resets all values on this [TestDisplay].
1150 ///
1151 /// See also:
1152 /// * [resetDevicePixelRatio] to reset [devicePixelRatio] specifically
1153 /// * [resetRefreshRate] to reset [refreshRate] specifically
1154 /// * [resetSize] to reset [size] specifically
1155 void reset() {
1156 resetDevicePixelRatio();
1157 resetRefreshRate();
1158 resetSize();
1159 }
1160
1161 /// This gives us some grace time when the dart:ui side adds something to
1162 /// [Display], and makes things easier when we do rolls to give
1163 /// us time to catch up.
1164 @override
1165 dynamic noSuchMethod(Invocation invocation) {
1166 return null;
1167 }
1168}
1169
1170// TODO(pdblasi-google): Remove this once the Display API is stable and supported on all platforms
1171class _UnsupportedDisplay implements TestDisplay {
1172 _UnsupportedDisplay(this._platformDispatcher, this._view, this.error);
1173
1174 final FlutterView _view;
1175 final Object? error;
1176
1177 @override
1178 final TestPlatformDispatcher _platformDispatcher;
1179
1180 @override
1181 double get devicePixelRatio => _devicePixelRatio ?? _view.devicePixelRatio;
1182 @override
1183 double? _devicePixelRatio;
1184 @override
1185 set devicePixelRatio(double value) {
1186 _devicePixelRatio = value;
1187 _platformDispatcher.onMetricsChanged?.call();
1188 }
1189
1190 @override
1191 void resetDevicePixelRatio() {
1192 _devicePixelRatio = null;
1193 _platformDispatcher.onMetricsChanged?.call();
1194 }
1195
1196 @override
1197 dynamic noSuchMethod(Invocation invocation) {
1198 throw UnsupportedError(
1199 'The Display API is unsupported in this context. '
1200 'As of the last metrics change on PlatformDispatcher, this was the error '
1201 'given when trying to prepare the display for testing: $error',
1202 );
1203 }
1204}
1205
1206/// Deprecated. Will be removed in a future version of Flutter.
1207///
1208/// This class has been deprecated to prepare for Flutter's upcoming support
1209/// for multiple views and multiple windows.
1210///
1211/// [SingletonFlutterWindow] that wraps another [SingletonFlutterWindow] and
1212/// allows faking of some properties for testing purposes.
1213///
1214/// Tests for certain widgets, e.g., [MaterialApp], might require faking certain
1215/// properties of a [SingletonFlutterWindow]. [TestWindow] facilitates the
1216/// faking of these properties by overriding the properties of a real
1217/// [SingletonFlutterWindow] with desired fake values. The binding used within
1218/// tests, [TestWidgetsFlutterBinding], contains a [TestWindow] that is used by
1219/// all tests.
1220///
1221/// ## Sample Code
1222///
1223/// A test can utilize a [TestWindow] in the following way:
1224///
1225/// ```dart
1226/// testWidgets('your test name here', (WidgetTester tester) async {
1227/// // Retrieve the TestWidgetsFlutterBinding.
1228/// final TestWidgetsFlutterBinding testBinding = tester.binding;
1229///
1230/// // Fake the desired properties of the TestWindow. All code running
1231/// // within this test will perceive the following fake text scale
1232/// // factor as the real text scale factor of the window.
1233/// testBinding.platformDispatcher.textScaleFactorTestValue = 2.5;
1234///
1235/// // Test code that depends on text scale factor here.
1236/// });
1237/// ```
1238///
1239/// The [TestWidgetsFlutterBinding] is recreated for each test and
1240/// therefore any fake values defined in one test will not persist
1241/// to the next.
1242///
1243/// If a test needs to override a real [SingletonFlutterWindow] property and
1244/// then later return to using the real [SingletonFlutterWindow] property,
1245/// [TestWindow] provides methods to clear each individual test value, e.g.,
1246/// [clearDevicePixelRatioTestValue].
1247///
1248/// To clear all fake test values in a [TestWindow], consider using
1249/// [clearAllTestValues].
1250///
1251/// See also:
1252///
1253/// * [TestPlatformDispatcher], which wraps a [PlatformDispatcher] for
1254/// testing purposes and is used by the [platformDispatcher] property of
1255/// this class.
1256@Deprecated(
1257 'Use TestPlatformDispatcher (via WidgetTester.platformDispatcher) or TestFlutterView (via WidgetTester.view) instead. '
1258 'Deprecated to prepare for the upcoming multi-window support. '
1259 'This feature was deprecated after v3.9.0-0.1.pre.',
1260)
1261class TestWindow implements SingletonFlutterWindow {
1262 /// Constructs a [TestWindow] that defers all behavior to the given
1263 /// [SingletonFlutterWindow] unless explicitly overridden for test purposes.
1264 @Deprecated(
1265 'Use TestPlatformDispatcher (via WidgetTester.platformDispatcher) or TestFlutterView (via WidgetTester.view) instead. '
1266 'Deprecated to prepare for the upcoming multi-window support. '
1267 'This feature was deprecated after v3.9.0-0.1.pre.',
1268 )
1269 TestWindow({required SingletonFlutterWindow window})
1270 : platformDispatcher = TestPlatformDispatcher(platformDispatcher: window.platformDispatcher);
1271
1272 /// Constructs a [TestWindow] that defers all behavior to the given
1273 /// [TestPlatformDispatcher] and its [TestPlatformDispatcher.implicitView].
1274 ///
1275 /// This class will not work when multiple views are present. If multiple view
1276 /// support is needed use [WidgetTester.platformDispatcher] and
1277 /// [WidgetTester.viewOf].
1278 ///
1279 /// See also:
1280 ///
1281 /// * [TestPlatformDispatcher] which allows faking of platform-wide values for
1282 /// testing purposes.
1283 /// * [TestFlutterView] which allows faking of view-specific values for
1284 /// testing purposes.
1285 @Deprecated(
1286 'Use TestPlatformDispatcher (via WidgetTester.platformDispatcher) or TestFlutterView (via WidgetTester.view) instead. '
1287 'Deprecated to prepare for the upcoming multi-window support. '
1288 'This feature was deprecated after v3.9.0-0.1.pre.',
1289 )
1290 TestWindow.fromPlatformDispatcher({
1291 @Deprecated(
1292 'Use WidgetTester.platformDispatcher instead. '
1293 'Deprecated to prepare for the upcoming multi-window support. '
1294 'This feature was deprecated after v3.9.0-0.1.pre.',
1295 )
1296 required this.platformDispatcher,
1297 });
1298
1299 @Deprecated(
1300 'Use WidgetTester.platformDispatcher instead. '
1301 'Deprecated to prepare for the upcoming multi-window support. '
1302 'This feature was deprecated after v3.9.0-0.1.pre.',
1303 )
1304 @override
1305 final TestPlatformDispatcher platformDispatcher;
1306
1307 TestFlutterView get _view => platformDispatcher.implicitView!;
1308
1309 @Deprecated(
1310 'Use WidgetTester.view.devicePixelRatio instead. '
1311 'Deprecated to prepare for the upcoming multi-window support. '
1312 'This feature was deprecated after v3.9.0-0.1.pre.',
1313 )
1314 @override
1315 double get devicePixelRatio => _view.devicePixelRatio;
1316
1317 /// Hides the real device pixel ratio and reports the given [devicePixelRatio]
1318 /// instead.
1319 @Deprecated(
1320 'Use WidgetTester.view.devicePixelRatio instead. '
1321 'Deprecated to prepare for the upcoming multi-window support. '
1322 'This feature was deprecated after v3.9.0-0.1.pre.',
1323 )
1324 // ignore: avoid_setters_without_getters
1325 set devicePixelRatioTestValue(double devicePixelRatio) {
1326 _view.devicePixelRatio = devicePixelRatio;
1327 }
1328
1329 /// Deletes any existing test device pixel ratio and returns to using the real
1330 /// device pixel ratio.
1331 @Deprecated(
1332 'Use WidgetTester.view.resetDevicePixelRatio() instead. '
1333 'Deprecated to prepare for the upcoming multi-window support. '
1334 'This feature was deprecated after v3.9.0-0.1.pre.',
1335 )
1336 void clearDevicePixelRatioTestValue() {
1337 _view.resetDevicePixelRatio();
1338 }
1339
1340 @Deprecated(
1341 'Use WidgetTester.view.physicalSize instead. '
1342 'Deprecated to prepare for the upcoming multi-window support. '
1343 'This feature was deprecated after v3.9.0-0.1.pre.',
1344 )
1345 @override
1346 Size get physicalSize => _view.physicalSize;
1347
1348 /// Hides the real physical size and reports the given [physicalSizeTestValue]
1349 /// instead.
1350 @Deprecated(
1351 'Use WidgetTester.view.physicalSize instead. '
1352 'Deprecated to prepare for the upcoming multi-window support. '
1353 'This feature was deprecated after v3.9.0-0.1.pre.',
1354 )
1355 // ignore: avoid_setters_without_getters
1356 set physicalSizeTestValue(Size physicalSizeTestValue) {
1357 _view.physicalSize = physicalSizeTestValue;
1358 }
1359
1360 /// Deletes any existing test physical size and returns to using the real
1361 /// physical size.
1362 @Deprecated(
1363 'Use WidgetTester.view.resetPhysicalSize() instead. '
1364 'Deprecated to prepare for the upcoming multi-window support. '
1365 'This feature was deprecated after v3.9.0-0.1.pre.',
1366 )
1367 void clearPhysicalSizeTestValue() {
1368 _view.resetPhysicalSize();
1369 }
1370
1371 @Deprecated(
1372 'Use WidgetTester.view.viewInsets instead. '
1373 'Deprecated to prepare for the upcoming multi-window support. '
1374 'This feature was deprecated after v3.9.0-0.1.pre.',
1375 )
1376 @override
1377 ViewPadding get viewInsets => _view.viewInsets;
1378
1379 /// Hides the real view insets and reports the given [viewInsetsTestValue]
1380 /// instead.
1381 ///
1382 /// Use [FakeViewPadding] to set this value for testing.
1383 @Deprecated(
1384 'Use WidgetTester.view.viewInsets instead. '
1385 'Deprecated to prepare for the upcoming multi-window support. '
1386 'This feature was deprecated after v3.9.0-0.1.pre.',
1387 )
1388 // ignore: avoid_setters_without_getters
1389 set viewInsetsTestValue(ViewPadding value) {
1390 _view.viewInsets = value is FakeViewPadding ? value : FakeViewPadding._wrap(value);
1391 }
1392
1393 /// Deletes any existing test view insets and returns to using the real view
1394 /// insets.
1395 @Deprecated(
1396 'Use WidgetTester.view.resetViewInsets() instead. '
1397 'Deprecated to prepare for the upcoming multi-window support. '
1398 'This feature was deprecated after v3.9.0-0.1.pre.',
1399 )
1400 void clearViewInsetsTestValue() {
1401 _view.resetViewInsets();
1402 }
1403
1404 @Deprecated(
1405 'Use WidgetTester.view.viewPadding instead. '
1406 'Deprecated to prepare for the upcoming multi-window support. '
1407 'This feature was deprecated after v3.9.0-0.1.pre.',
1408 )
1409 @override
1410 ViewPadding get viewPadding => _view.viewPadding;
1411
1412 /// Hides the real view padding and reports the given [paddingTestValue]
1413 /// instead.
1414 ///
1415 /// Use [FakeViewPadding] to set this value for testing.
1416 @Deprecated(
1417 'Use WidgetTester.view.viewPadding instead. '
1418 'Deprecated to prepare for the upcoming multi-window support. '
1419 'This feature was deprecated after v3.9.0-0.1.pre.',
1420 )
1421 // ignore: avoid_setters_without_getters
1422 set viewPaddingTestValue(ViewPadding value) {
1423 _view.viewPadding = value is FakeViewPadding ? value : FakeViewPadding._wrap(value);
1424 }
1425
1426 /// Deletes any existing test view padding and returns to using the real
1427 /// viewPadding.
1428 @Deprecated(
1429 'Use WidgetTester.view.resetViewPadding() instead. '
1430 'Deprecated to prepare for the upcoming multi-window support. '
1431 'This feature was deprecated after v3.9.0-0.1.pre.',
1432 )
1433 void clearViewPaddingTestValue() {
1434 _view.resetViewPadding();
1435 }
1436
1437 @Deprecated(
1438 'Use WidgetTester.view.padding instead. '
1439 'Deprecated to prepare for the upcoming multi-window support. '
1440 'This feature was deprecated after v3.9.0-0.1.pre.',
1441 )
1442 @override
1443 ViewPadding get padding => _view.padding;
1444
1445 /// Hides the real padding and reports the given [paddingTestValue] instead.
1446 ///
1447 /// Use [FakeViewPadding] to set this value for testing.
1448 @Deprecated(
1449 'Use WidgetTester.view.padding instead. '
1450 'Deprecated to prepare for the upcoming multi-window support. '
1451 'This feature was deprecated after v3.9.0-0.1.pre.',
1452 )
1453 // ignore: avoid_setters_without_getters
1454 set paddingTestValue(ViewPadding value) {
1455 _view.padding = value is FakeViewPadding ? value : FakeViewPadding._wrap(value);
1456 }
1457
1458 /// Deletes any existing test padding and returns to using the real padding.
1459 @Deprecated(
1460 'Use WidgetTester.view.resetPadding() instead. '
1461 'Deprecated to prepare for the upcoming multi-window support. '
1462 'This feature was deprecated after v3.9.0-0.1.pre.',
1463 )
1464 void clearPaddingTestValue() {
1465 _view.resetPadding();
1466 }
1467
1468 @Deprecated(
1469 'Use WidgetTester.view.gestureSettings instead. '
1470 'Deprecated to prepare for the upcoming multi-window support. '
1471 'This feature was deprecated after v3.9.0-0.1.pre.',
1472 )
1473 @override
1474 GestureSettings get gestureSettings => _view.gestureSettings;
1475
1476 /// Hides the real gesture settings and reports the given [gestureSettingsTestValue] instead.
1477 @Deprecated(
1478 'Use WidgetTester.view.gestureSettings instead. '
1479 'Deprecated to prepare for the upcoming multi-window support. '
1480 'This feature was deprecated after v3.9.0-0.1.pre.',
1481 )
1482 // ignore: avoid_setters_without_getters
1483 set gestureSettingsTestValue(GestureSettings gestureSettingsTestValue) {
1484 _view.gestureSettings = gestureSettingsTestValue;
1485 }
1486
1487 /// Deletes any existing test gesture settings and returns to using the real gesture settings.
1488 @Deprecated(
1489 'Use WidgetTester.view.resetGestureSettings() instead. '
1490 'Deprecated to prepare for the upcoming multi-window support. '
1491 'This feature was deprecated after v3.9.0-0.1.pre.',
1492 )
1493 void clearGestureSettingsTestValue() {
1494 _view.resetGestureSettings();
1495 }
1496
1497 @Deprecated(
1498 'Use WidgetTester.view.displayFeatures instead. '
1499 'Deprecated to prepare for the upcoming multi-window support. '
1500 'This feature was deprecated after v3.9.0-0.1.pre.',
1501 )
1502 @override
1503 List<DisplayFeature> get displayFeatures => _view.displayFeatures;
1504
1505 /// Hides the real displayFeatures and reports the given [displayFeaturesTestValue] instead.
1506 @Deprecated(
1507 'Use WidgetTester.view.displayFeatures instead. '
1508 'Deprecated to prepare for the upcoming multi-window support. '
1509 'This feature was deprecated after v3.9.0-0.1.pre.',
1510 )
1511 // ignore: avoid_setters_without_getters
1512 set displayFeaturesTestValue(List<DisplayFeature> displayFeaturesTestValue) {
1513 _view.displayFeatures = displayFeaturesTestValue;
1514 }
1515
1516 /// Deletes any existing test padding and returns to using the real padding.
1517 @Deprecated(
1518 'Use WidgetTester.view.resetDisplayFeatures() instead. '
1519 'Deprecated to prepare for the upcoming multi-window support. '
1520 'This feature was deprecated after v3.9.0-0.1.pre.',
1521 )
1522 void clearDisplayFeaturesTestValue() {
1523 _view.resetDisplayFeatures();
1524 }
1525
1526 @Deprecated(
1527 'Use WidgetTester.view.systemGestureInsets instead. '
1528 'Deprecated to prepare for the upcoming multi-window support. '
1529 'This feature was deprecated after v3.9.0-0.1.pre.',
1530 )
1531 @override
1532 ViewPadding get systemGestureInsets => _view.systemGestureInsets;
1533
1534 /// Hides the real system gesture insets and reports the given
1535 /// [systemGestureInsetsTestValue] instead.
1536 ///
1537 /// Use [FakeViewPadding] to set this value for testing.
1538 @Deprecated(
1539 'Use WidgetTester.view.systemGestureInsets instead. '
1540 'Deprecated to prepare for the upcoming multi-window support. '
1541 'This feature was deprecated after v3.9.0-0.1.pre.',
1542 )
1543 // ignore: avoid_setters_without_getters
1544 set systemGestureInsetsTestValue(ViewPadding value) {
1545 _view.systemGestureInsets = value is FakeViewPadding ? value : FakeViewPadding._wrap(value);
1546 }
1547
1548 /// Deletes any existing test system gesture insets and returns to using the real system gesture insets.
1549 @Deprecated(
1550 'Use WidgetTester.view.resetSystemGestureInsets() instead. '
1551 'Deprecated to prepare for the upcoming multi-window support. '
1552 'This feature was deprecated after v3.9.0-0.1.pre.',
1553 )
1554 void clearSystemGestureInsetsTestValue() {
1555 _view.resetSystemGestureInsets();
1556 }
1557
1558 @Deprecated(
1559 'Use WidgetTester.platformDispatcher.onMetricsChanged instead. '
1560 'Deprecated to prepare for the upcoming multi-window support. '
1561 'This feature was deprecated after v3.9.0-0.1.pre.',
1562 )
1563 @override
1564 VoidCallback? get onMetricsChanged => platformDispatcher.onMetricsChanged;
1565 @Deprecated(
1566 'Use WidgetTester.platformDispatcher.onMetricsChanged instead. '
1567 'Deprecated to prepare for the upcoming multi-window support. '
1568 'This feature was deprecated after v3.9.0-0.1.pre.',
1569 )
1570 @override
1571 set onMetricsChanged(VoidCallback? callback) {
1572 platformDispatcher.onMetricsChanged = callback;
1573 }
1574
1575 @Deprecated(
1576 'Use WidgetTester.platformDispatcher.locale instead. '
1577 'Deprecated to prepare for the upcoming multi-window support. '
1578 'This feature was deprecated after v3.9.0-0.1.pre.',
1579 )
1580 @override
1581 Locale get locale => platformDispatcher.locale;
1582
1583 @Deprecated(
1584 'Use WidgetTester.platformDispatcher.locales instead. '
1585 'Deprecated to prepare for the upcoming multi-window support. '
1586 'This feature was deprecated after v3.9.0-0.1.pre.',
1587 )
1588 @override
1589 List<Locale> get locales => platformDispatcher.locales;
1590
1591 @Deprecated(
1592 'Use WidgetTester.platformDispatcher.onLocaleChanged instead. '
1593 'Deprecated to prepare for the upcoming multi-window support. '
1594 'This feature was deprecated after v3.9.0-0.1.pre.',
1595 )
1596 @override
1597 VoidCallback? get onLocaleChanged => platformDispatcher.onLocaleChanged;
1598 @Deprecated(
1599 'Use WidgetTester.platformDispatcher.onLocaleChanged instead. '
1600 'Deprecated to prepare for the upcoming multi-window support. '
1601 'This feature was deprecated after v3.9.0-0.1.pre.',
1602 )
1603 @override
1604 set onLocaleChanged(VoidCallback? callback) {
1605 platformDispatcher.onLocaleChanged = callback;
1606 }
1607
1608 @Deprecated(
1609 'Use WidgetTester.platformDispatcher.initialLifecycleState instead. '
1610 'Deprecated to prepare for the upcoming multi-window support. '
1611 'This feature was deprecated after v3.9.0-0.1.pre.',
1612 )
1613 @override
1614 String get initialLifecycleState => platformDispatcher.initialLifecycleState;
1615
1616 @Deprecated(
1617 'Use WidgetTester.platformDispatcher.textScaleFactor instead. '
1618 'Deprecated to prepare for the upcoming multi-window support. '
1619 'This feature was deprecated after v3.9.0-0.1.pre.',
1620 )
1621 @override
1622 double get textScaleFactor => platformDispatcher.textScaleFactor;
1623
1624 @Deprecated(
1625 'Use WidgetTester.platformDispatcher.platformBrightness instead. '
1626 'Deprecated to prepare for the upcoming multi-window support. '
1627 'This feature was deprecated after v3.9.0-0.1.pre.',
1628 )
1629 @override
1630 Brightness get platformBrightness => platformDispatcher.platformBrightness;
1631 @Deprecated(
1632 'Use WidgetTester.platformDispatcher.onPlatformBrightnessChanged instead. '
1633 'Deprecated to prepare for the upcoming multi-window support. '
1634 'This feature was deprecated after v3.9.0-0.1.pre.',
1635 )
1636 @override
1637 VoidCallback? get onPlatformBrightnessChanged => platformDispatcher.onPlatformBrightnessChanged;
1638 @Deprecated(
1639 'Use WidgetTester.platformDispatcher.onPlatformBrightnessChanged instead. '
1640 'Deprecated to prepare for the upcoming multi-window support. '
1641 'This feature was deprecated after v3.9.0-0.1.pre.',
1642 )
1643 @override
1644 set onPlatformBrightnessChanged(VoidCallback? callback) {
1645 platformDispatcher.onPlatformBrightnessChanged = callback;
1646 }
1647
1648 @Deprecated(
1649 'Use WidgetTester.platformDispatcher.alwaysUse24HourFormat instead. '
1650 'Deprecated to prepare for the upcoming multi-window support. '
1651 'This feature was deprecated after v3.9.0-0.1.pre.',
1652 )
1653 @override
1654 bool get alwaysUse24HourFormat => platformDispatcher.alwaysUse24HourFormat;
1655
1656 @Deprecated(
1657 'Use WidgetTester.platformDispatcher.onTextScaleFactorChanged instead. '
1658 'Deprecated to prepare for the upcoming multi-window support. '
1659 'This feature was deprecated after v3.9.0-0.1.pre.',
1660 )
1661 @override
1662 VoidCallback? get onTextScaleFactorChanged => platformDispatcher.onTextScaleFactorChanged;
1663 @Deprecated(
1664 'Use WidgetTester.platformDispatcher.onTextScaleFactorChanged instead. '
1665 'Deprecated to prepare for the upcoming multi-window support. '
1666 'This feature was deprecated after v3.9.0-0.1.pre.',
1667 )
1668 @override
1669 set onTextScaleFactorChanged(VoidCallback? callback) {
1670 platformDispatcher.onTextScaleFactorChanged = callback;
1671 }
1672
1673 @Deprecated(
1674 'Use WidgetTester.platformDispatcher.nativeSpellCheckServiceDefined instead. '
1675 'Deprecated to prepare for the upcoming multi-window support. '
1676 'This feature was deprecated after v3.9.0-0.1.pre.',
1677 )
1678 @override
1679 bool get nativeSpellCheckServiceDefined => platformDispatcher.nativeSpellCheckServiceDefined;
1680 @Deprecated(
1681 'Use WidgetTester.platformDispatcher.nativeSpellCheckServiceDefinedTestValue instead. '
1682 'Deprecated to prepare for the upcoming multi-window support. '
1683 'This feature was deprecated after v3.9.0-0.1.pre.',
1684 )
1685 // ignore: avoid_setters_without_getters
1686 set nativeSpellCheckServiceDefinedTestValue(bool nativeSpellCheckServiceDefinedTestValue) {
1687 platformDispatcher.nativeSpellCheckServiceDefinedTestValue =
1688 nativeSpellCheckServiceDefinedTestValue;
1689 }
1690
1691 @Deprecated(
1692 'Use WidgetTester.platformDispatcher.brieflyShowPassword instead. '
1693 'Deprecated to prepare for the upcoming multi-window support. '
1694 'This feature was deprecated after v3.9.0-0.1.pre.',
1695 )
1696 @override
1697 bool get brieflyShowPassword => platformDispatcher.brieflyShowPassword;
1698
1699 @Deprecated(
1700 'Use WidgetTester.platformDispatcher.onBeginFrame instead. '
1701 'Deprecated to prepare for the upcoming multi-window support. '
1702 'This feature was deprecated after v3.9.0-0.1.pre.',
1703 )
1704 @override
1705 FrameCallback? get onBeginFrame => platformDispatcher.onBeginFrame;
1706 @Deprecated(
1707 'Use WidgetTester.platformDispatcher.onBeginFrame instead. '
1708 'Deprecated to prepare for the upcoming multi-window support. '
1709 'This feature was deprecated after v3.9.0-0.1.pre.',
1710 )
1711 @override
1712 set onBeginFrame(FrameCallback? callback) {
1713 platformDispatcher.onBeginFrame = callback;
1714 }
1715
1716 @Deprecated(
1717 'Use WidgetTester.platformDispatcher.onDrawFrame instead. '
1718 'Deprecated to prepare for the upcoming multi-window support. '
1719 'This feature was deprecated after v3.9.0-0.1.pre.',
1720 )
1721 @override
1722 VoidCallback? get onDrawFrame => platformDispatcher.onDrawFrame;
1723 @Deprecated(
1724 'Use WidgetTester.platformDispatcher.onDrawFrame instead. '
1725 'Deprecated to prepare for the upcoming multi-window support. '
1726 'This feature was deprecated after v3.9.0-0.1.pre.',
1727 )
1728 @override
1729 set onDrawFrame(VoidCallback? callback) {
1730 platformDispatcher.onDrawFrame = callback;
1731 }
1732
1733 @Deprecated(
1734 'Use WidgetTester.platformDispatcher.onReportTimings instead. '
1735 'Deprecated to prepare for the upcoming multi-window support. '
1736 'This feature was deprecated after v3.9.0-0.1.pre.',
1737 )
1738 @override
1739 TimingsCallback? get onReportTimings => platformDispatcher.onReportTimings;
1740 @Deprecated(
1741 'Use WidgetTester.platformDispatcher.onReportTimings instead. '
1742 'Deprecated to prepare for the upcoming multi-window support. '
1743 'This feature was deprecated after v3.9.0-0.1.pre.',
1744 )
1745 @override
1746 set onReportTimings(TimingsCallback? callback) {
1747 platformDispatcher.onReportTimings = callback;
1748 }
1749
1750 @Deprecated(
1751 'Use WidgetTester.platformDispatcher.onPointerDataPacket instead. '
1752 'Deprecated to prepare for the upcoming multi-window support. '
1753 'This feature was deprecated after v3.9.0-0.1.pre.',
1754 )
1755 @override
1756 PointerDataPacketCallback? get onPointerDataPacket => platformDispatcher.onPointerDataPacket;
1757 @Deprecated(
1758 'Use WidgetTester.platformDispatcher.onPointerDataPacket instead. '
1759 'Deprecated to prepare for the upcoming multi-window support. '
1760 'This feature was deprecated after v3.9.0-0.1.pre.',
1761 )
1762 @override
1763 set onPointerDataPacket(PointerDataPacketCallback? callback) {
1764 platformDispatcher.onPointerDataPacket = callback;
1765 }
1766
1767 @Deprecated(
1768 'Use WidgetTester.platformDispatcher.defaultRouteName instead. '
1769 'Deprecated to prepare for the upcoming multi-window support. '
1770 'This feature was deprecated after v3.9.0-0.1.pre.',
1771 )
1772 @override
1773 String get defaultRouteName => platformDispatcher.defaultRouteName;
1774
1775 @Deprecated(
1776 'Use WidgetTester.platformDispatcher.scheduleFrame() instead. '
1777 'Deprecated to prepare for the upcoming multi-window support. '
1778 'This feature was deprecated after v3.9.0-0.1.pre.',
1779 )
1780 @override
1781 void scheduleFrame() {
1782 platformDispatcher.scheduleFrame();
1783 }
1784
1785 @Deprecated(
1786 'Use WidgetTester.view.render(scene) instead. '
1787 'Deprecated to prepare for the upcoming multi-window support. '
1788 'This feature was deprecated after v3.9.0-0.1.pre.',
1789 )
1790 @override
1791 void render(Scene scene, {Size? size}) {
1792 _view.render(scene, size: size);
1793 }
1794
1795 @Deprecated(
1796 'Use WidgetTester.platformDispatcher.semanticsEnabled instead. '
1797 'Deprecated to prepare for the upcoming multi-window support. '
1798 'This feature was deprecated after v3.9.0-0.1.pre.',
1799 )
1800 @override
1801 bool get semanticsEnabled => platformDispatcher.semanticsEnabled;
1802
1803 @Deprecated(
1804 'Use WidgetTester.platformDispatcher.onSemanticsEnabledChanged instead. '
1805 'Deprecated to prepare for the upcoming multi-window support. '
1806 'This feature was deprecated after v3.9.0-0.1.pre.',
1807 )
1808 @override
1809 VoidCallback? get onSemanticsEnabledChanged => platformDispatcher.onSemanticsEnabledChanged;
1810 @Deprecated(
1811 'Use WidgetTester.platformDispatcher.onSemanticsEnabledChanged instead. '
1812 'Deprecated to prepare for the upcoming multi-window support. '
1813 'This feature was deprecated after v3.9.0-0.1.pre.',
1814 )
1815 @override
1816 set onSemanticsEnabledChanged(VoidCallback? callback) {
1817 platformDispatcher.onSemanticsEnabledChanged = callback;
1818 }
1819
1820 @Deprecated(
1821 'Use WidgetTester.platformDispatcher.accessibilityFeatures instead. '
1822 'Deprecated to prepare for the upcoming multi-window support. '
1823 'This feature was deprecated after v3.9.0-0.1.pre.',
1824 )
1825 @override
1826 AccessibilityFeatures get accessibilityFeatures => platformDispatcher.accessibilityFeatures;
1827
1828 @Deprecated(
1829 'Use WidgetTester.platformDispatcher.onAccessibilityFeaturesChanged instead. '
1830 'Deprecated to prepare for the upcoming multi-window support. '
1831 'This feature was deprecated after v3.9.0-0.1.pre.',
1832 )
1833 @override
1834 VoidCallback? get onAccessibilityFeaturesChanged =>
1835 platformDispatcher.onAccessibilityFeaturesChanged;
1836 @Deprecated(
1837 'Use WidgetTester.platformDispatcher.onAccessibilityFeaturesChanged instead. '
1838 'Deprecated to prepare for the upcoming multi-window support. '
1839 'This feature was deprecated after v3.9.0-0.1.pre.',
1840 )
1841 @override
1842 set onAccessibilityFeaturesChanged(VoidCallback? callback) {
1843 platformDispatcher.onAccessibilityFeaturesChanged = callback;
1844 }
1845
1846 @Deprecated(
1847 'Use WidgetTester.view.updateSemantics(update) instead. '
1848 'Deprecated to prepare for the upcoming multi-window support. '
1849 'This feature was deprecated after v3.9.0-0.1.pre.',
1850 )
1851 @override
1852 void updateSemantics(SemanticsUpdate update) {
1853 _view.updateSemantics(update);
1854 }
1855
1856 @Deprecated(
1857 'Use WidgetTester.platformDispatcher.setIsolateDebugName(name) instead. '
1858 'Deprecated to prepare for the upcoming multi-window support. '
1859 'This feature was deprecated after v3.9.0-0.1.pre.',
1860 )
1861 @override
1862 void setIsolateDebugName(String name) {
1863 platformDispatcher.setIsolateDebugName(name);
1864 }
1865
1866 @Deprecated(
1867 'Use WidgetTester.platformDispatcher.sendPlatformMessage(name, data, callback) instead. '
1868 'Deprecated to prepare for the upcoming multi-window support. '
1869 'This feature was deprecated after v3.9.0-0.1.pre.',
1870 )
1871 @override
1872 void sendPlatformMessage(String name, ByteData? data, PlatformMessageResponseCallback? callback) {
1873 platformDispatcher.sendPlatformMessage(name, data, callback);
1874 }
1875
1876 /// Delete any test value properties that have been set on this [TestWindow]
1877 /// as well as its [platformDispatcher].
1878 ///
1879 /// After calling this, the real [SingletonFlutterWindow] and
1880 /// [PlatformDispatcher] values are reported again.
1881 ///
1882 /// If desired, clearing of properties can be done on an individual basis,
1883 /// e.g., [clearDevicePixelRatioTestValue].
1884 @Deprecated(
1885 'Use WidgetTester.platformDispatcher.clearAllTestValues() and WidgetTester.view.reset() instead. '
1886 'Deprecated to prepare for the upcoming multi-window support. '
1887 'This feature was deprecated after v3.9.0-0.1.pre.',
1888 )
1889 void clearAllTestValues() {
1890 clearDevicePixelRatioTestValue();
1891 clearPaddingTestValue();
1892 clearGestureSettingsTestValue();
1893 clearDisplayFeaturesTestValue();
1894 clearPhysicalSizeTestValue();
1895 clearViewInsetsTestValue();
1896 platformDispatcher.clearAllTestValues();
1897 }
1898
1899 @override
1900 @Deprecated(
1901 'Use WidgetTester.platformDispatcher.onFrameDataChanged instead. '
1902 'Deprecated to prepare for the upcoming multi-window support. '
1903 'This feature was deprecated after v3.9.0-0.1.pre.',
1904 )
1905 VoidCallback? get onFrameDataChanged => platformDispatcher.onFrameDataChanged;
1906 @Deprecated(
1907 'Use WidgetTester.platformDispatcher.onFrameDataChanged instead. '
1908 'Deprecated to prepare for the upcoming multi-window support. '
1909 'This feature was deprecated after v3.9.0-0.1.pre.',
1910 )
1911 @override
1912 set onFrameDataChanged(VoidCallback? value) {
1913 platformDispatcher.onFrameDataChanged = value;
1914 }
1915
1916 @Deprecated(
1917 'Use WidgetTester.platformDispatcher.onKeyData instead. '
1918 'Deprecated to prepare for the upcoming multi-window support. '
1919 'This feature was deprecated after v3.9.0-0.1.pre.',
1920 )
1921 @override
1922 KeyDataCallback? get onKeyData => platformDispatcher.onKeyData;
1923 @Deprecated(
1924 'Use WidgetTester.platformDispatcher.onKeyData instead. '
1925 'Deprecated to prepare for the upcoming multi-window support. '
1926 'This feature was deprecated after v3.9.0-0.1.pre.',
1927 )
1928 @override
1929 set onKeyData(KeyDataCallback? value) {
1930 platformDispatcher.onKeyData = value;
1931 }
1932
1933 @Deprecated(
1934 'Use WidgetTester.platformDispatcher.onSystemFontFamilyChanged instead. '
1935 'Deprecated to prepare for the upcoming multi-window support. '
1936 'This feature was deprecated after v3.9.0-0.1.pre.',
1937 )
1938 @override
1939 VoidCallback? get onSystemFontFamilyChanged => platformDispatcher.onSystemFontFamilyChanged;
1940 @Deprecated(
1941 'Use WidgetTester.platformDispatcher.onSystemFontFamilyChanged instead. '
1942 'Deprecated to prepare for the upcoming multi-window support. '
1943 'This feature was deprecated after v3.9.0-0.1.pre.',
1944 )
1945 @override
1946 set onSystemFontFamilyChanged(VoidCallback? value) {
1947 platformDispatcher.onSystemFontFamilyChanged = value;
1948 }
1949
1950 @Deprecated(
1951 'Use WidgetTester.platformDispatcher.computePlatformResolvedLocale(supportedLocales) instead. '
1952 'Deprecated to prepare for the upcoming multi-window support. '
1953 'This feature was deprecated after v3.9.0-0.1.pre.',
1954 )
1955 @override
1956 Locale? computePlatformResolvedLocale(List<Locale> supportedLocales) {
1957 return platformDispatcher.computePlatformResolvedLocale(supportedLocales);
1958 }
1959
1960 @Deprecated(
1961 'Use WidgetTester.platformDispatcher.frameData instead. '
1962 'Deprecated to prepare for the upcoming multi-window support. '
1963 'This feature was deprecated after v3.9.0-0.1.pre.',
1964 )
1965 @override
1966 FrameData get frameData => platformDispatcher.frameData;
1967
1968 @Deprecated(
1969 'Use WidgetTester.platformDispatcher.systemFontFamily instead. '
1970 'Deprecated to prepare for the upcoming multi-window support. '
1971 'This feature was deprecated after v3.9.0-0.1.pre.',
1972 )
1973 @override
1974 String? get systemFontFamily => platformDispatcher.systemFontFamily;
1975
1976 @Deprecated(
1977 'Use WidgetTester.view.viewId instead. '
1978 'Deprecated to prepare for the upcoming multi-window support. '
1979 'This feature was deprecated after v3.9.0-0.1.pre.',
1980 )
1981 @override
1982 int get viewId => _view.viewId;
1983
1984 /// This gives us some grace time when the dart:ui side adds something to
1985 /// [SingletonFlutterWindow], and makes things easier when we do rolls to give
1986 /// us time to catch up.
1987 @override
1988 dynamic noSuchMethod(Invocation invocation) {
1989 return null;
1990 }
1991}
1992

Provided by KDAB

Privacy Policy
Learn more about Flutter for embedded and desktop on industrialflutter.com