[go: nahoru, domu]

Skip to content

Commit

Permalink
Remove single-view assumption from material library (#117486)
Browse files Browse the repository at this point in the history
* Remove single-view assumption from material library

* one widget
  • Loading branch information
goderbauer committed Jan 25, 2023
1 parent 02a9c15 commit 766e4d2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/material/dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1358,9 +1358,9 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
Orientation _getOrientation(BuildContext context) {
Orientation? result = MediaQuery.maybeOrientationOf(context);
if (result == null) {
// If there's no MediaQuery, then use the window aspect to determine
// If there's no MediaQuery, then use the view aspect to determine
// orientation.
final Size size = WidgetsBinding.instance.window.physicalSize;
final Size size = View.of(context).physicalSize;
result = size.width > size.height ? Orientation.landscape : Orientation.portrait;
}
return result;
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> with Restora
// If screen reader is in use, make the hint text say hours/minutes.
// Otherwise, remove the hint text when focused because the centered cursor
// appears odd above the hint text.
final String? hintText = MediaQuery.accessibleNavigationOf(context) || WidgetsBinding.instance.window.semanticsEnabled
final String? hintText = MediaQuery.accessibleNavigationOf(context) || View.of(context).platformDispatcher.semanticsEnabled
? widget.semanticHintText
: (focusNode.hasFocus ? null : _formattedValue);

Expand Down
8 changes: 5 additions & 3 deletions packages/flutter/lib/src/widgets/binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ abstract class WidgetsBindingObserver {
/// @override
/// void initState() {
/// super.initState();
/// _lastSize = WidgetsBinding.instance.window.physicalSize;
/// // [View.of] exposes the view from `WidgetsBinding.instance.platformDispatcher.views`
/// // into which this widget is drawn.
/// _lastSize = View.of(context).physicalSize;
/// WidgetsBinding.instance.addObserver(this);
/// }
///
Expand All @@ -129,7 +131,7 @@ abstract class WidgetsBindingObserver {
///
/// @override
/// void didChangeMetrics() {
/// setState(() { _lastSize = WidgetsBinding.instance.window.physicalSize; });
/// setState(() { _lastSize = View.of(context).physicalSize; });
/// }
///
/// @override
Expand Down Expand Up @@ -186,7 +188,7 @@ abstract class WidgetsBindingObserver {
///
/// @override
/// void didChangeTextScaleFactor() {
/// setState(() { _lastTextScaleFactor = WidgetsBinding.instance.window.textScaleFactor; });
/// setState(() { _lastTextScaleFactor = WidgetsBinding.instance.platformDispatcher.textScaleFactor; });
/// }
///
/// @override
Expand Down

0 comments on commit 766e4d2

Please sign in to comment.