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

Commit 766e4d2

Browse files
authored
Remove single-view assumption from material library (#117486)
* Remove single-view assumption from material library * one widget
1 parent 02a9c15 commit 766e4d2

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

packages/flutter/lib/src/material/dropdown.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,9 +1358,9 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
13581358
Orientation _getOrientation(BuildContext context) {
13591359
Orientation? result = MediaQuery.maybeOrientationOf(context);
13601360
if (result == null) {
1361-
// If there's no MediaQuery, then use the window aspect to determine
1361+
// If there's no MediaQuery, then use the view aspect to determine
13621362
// orientation.
1363-
final Size size = WidgetsBinding.instance.window.physicalSize;
1363+
final Size size = View.of(context).physicalSize;
13641364
result = size.width > size.height ? Orientation.landscape : Orientation.portrait;
13651365
}
13661366
return result;

packages/flutter/lib/src/material/time_picker.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2053,7 +2053,7 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> with Restora
20532053
// If screen reader is in use, make the hint text say hours/minutes.
20542054
// Otherwise, remove the hint text when focused because the centered cursor
20552055
// appears odd above the hint text.
2056-
final String? hintText = MediaQuery.accessibleNavigationOf(context) || WidgetsBinding.instance.window.semanticsEnabled
2056+
final String? hintText = MediaQuery.accessibleNavigationOf(context) || View.of(context).platformDispatcher.semanticsEnabled
20572057
? widget.semanticHintText
20582058
: (focusNode.hasFocus ? null : _formattedValue);
20592059

packages/flutter/lib/src/widgets/binding.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ abstract class WidgetsBindingObserver {
117117
/// @override
118118
/// void initState() {
119119
/// super.initState();
120-
/// _lastSize = WidgetsBinding.instance.window.physicalSize;
120+
/// // [View.of] exposes the view from `WidgetsBinding.instance.platformDispatcher.views`
121+
/// // into which this widget is drawn.
122+
/// _lastSize = View.of(context).physicalSize;
121123
/// WidgetsBinding.instance.addObserver(this);
122124
/// }
123125
///
@@ -129,7 +131,7 @@ abstract class WidgetsBindingObserver {
129131
///
130132
/// @override
131133
/// void didChangeMetrics() {
132-
/// setState(() { _lastSize = WidgetsBinding.instance.window.physicalSize; });
134+
/// setState(() { _lastSize = View.of(context).physicalSize; });
133135
/// }
134136
///
135137
/// @override
@@ -186,7 +188,7 @@ abstract class WidgetsBindingObserver {
186188
///
187189
/// @override
188190
/// void didChangeTextScaleFactor() {
189-
/// setState(() { _lastTextScaleFactor = WidgetsBinding.instance.window.textScaleFactor; });
191+
/// setState(() { _lastTextScaleFactor = WidgetsBinding.instance.platformDispatcher.textScaleFactor; });
190192
/// }
191193
///
192194
/// @override

0 commit comments

Comments
 (0)