Skip to content

Commit b8d5d9c

Browse files
authored
Revert "Remove single-view assumption from widgets library (#117480)" (#117545)
This reverts commit b8b3567.
1 parent 95ff839 commit b8d5d9c

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

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

+4-6
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import 'text_editing_intents.dart';
4343
import 'text_selection.dart';
4444
import 'text_selection_toolbar_anchors.dart';
4545
import 'ticker_provider.dart';
46-
import 'view.dart';
4746
import 'widget_span.dart';
4847

4948
export 'package:flutter/services.dart' show SelectionChangedCause, SmartDashesType, SmartQuotesType, TextEditingValue, TextInputType, TextSelection;
@@ -3304,18 +3303,17 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
33043303

33053304
@override
33063305
void didChangeMetrics() {
3307-
final ui.FlutterView view = View.of(context);
3308-
if (_lastBottomViewInset != view.viewInsets.bottom) {
3306+
if (_lastBottomViewInset != WidgetsBinding.instance.window.viewInsets.bottom) {
33093307
SchedulerBinding.instance.addPostFrameCallback((Duration _) {
33103308
_selectionOverlay?.updateForScroll();
33113309
});
3312-
if (_lastBottomViewInset < view.viewInsets.bottom) {
3310+
if (_lastBottomViewInset < WidgetsBinding.instance.window.viewInsets.bottom) {
33133311
// Because the metrics change signal from engine will come here every frame
33143312
// (on both iOS and Android). So we don't need to show caret with animation.
33153313
_scheduleShowCaretOnScreen(withAnimation: false);
33163314
}
33173315
}
3318-
_lastBottomViewInset = view.viewInsets.bottom;
3316+
_lastBottomViewInset = WidgetsBinding.instance.window.viewInsets.bottom;
33193317
}
33203318

33213319
Future<void> _performSpellCheck(final String text) async {
@@ -3518,7 +3516,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
35183516
if (_hasFocus) {
35193517
// Listen for changing viewInsets, which indicates keyboard showing up.
35203518
WidgetsBinding.instance.addObserver(this);
3521-
_lastBottomViewInset = View.of(context).viewInsets.bottom;
3519+
_lastBottomViewInset = WidgetsBinding.instance.window.viewInsets.bottom;
35223520
if (!widget.readOnly) {
35233521
_scheduleShowCaretOnScreen(withAnimation: true);
35243522
}

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'framework.dart';
1313
import 'overscroll_indicator.dart';
1414
import 'scroll_metrics.dart';
1515
import 'scroll_simulation.dart';
16-
import 'view.dart';
1716

1817
export 'package:flutter/physics.dart' show ScrollSpringSimulation, Simulation, Tolerance;
1918

@@ -252,7 +251,7 @@ class ScrollPhysics {
252251
assert(metrics != null);
253252
assert(context != null);
254253
if (parent == null) {
255-
final double maxPhysicalPixels = View.of(context).physicalSize.longestSide;
254+
final double maxPhysicalPixels = WidgetsBinding.instance.window.physicalSize.longestSide;
256255
return velocity.abs() > maxPhysicalPixels;
257256
}
258257
return parent!.recommendDeferredLoading(velocity, metrics, context);

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import 'basic.dart';
1212
import 'binding.dart';
1313
import 'framework.dart';
1414
import 'gesture_detector.dart';
15-
import 'view.dart';
1615

1716
/// A widget that visualizes the semantics for the child.
1817
///
@@ -97,7 +96,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi
9796
Offset? _lastPointerDownLocation;
9897
void _handlePointerDown(PointerDownEvent event) {
9998
setState(() {
100-
_lastPointerDownLocation = event.position * View.of(context).devicePixelRatio;
99+
_lastPointerDownLocation = event.position * WidgetsBinding.instance.window.devicePixelRatio;
101100
});
102101
// TODO(ianh): Use a gesture recognizer so that we can reset the
103102
// _lastPointerDownLocation when none of the other gesture recognizers win.
@@ -160,7 +159,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi
160159
_pipelineOwner,
161160
_client.generation,
162161
_lastPointerDownLocation, // in physical pixels
163-
View.of(context).devicePixelRatio,
162+
WidgetsBinding.instance.window.devicePixelRatio,
164163
widget.labelStyle,
165164
),
166165
child: GestureDetector(

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import 'dart:math' as math;
1010
import 'dart:ui' as ui
1111
show
1212
ClipOp,
13-
FlutterView,
1413
Image,
1514
ImageByteFormat,
1615
Paragraph,
@@ -31,7 +30,6 @@ import 'debug.dart';
3130
import 'framework.dart';
3231
import 'gesture_detector.dart';
3332
import 'service_extensions.dart';
34-
import 'view.dart';
3533

3634
/// Signature for the builder callback used by
3735
/// [WidgetInspector.selectButtonBuilder].
@@ -2728,8 +2726,7 @@ class _WidgetInspectorState extends State<WidgetInspector>
27282726
// on the edge of the display. If the pointer is being dragged off the edge
27292727
// of the display we do not want to select anything. A user can still select
27302728
// a widget that is only at the exact screen margin by tapping.
2731-
final ui.FlutterView view = View.of(context);
2732-
final Rect bounds = (Offset.zero & (view.physicalSize / view.devicePixelRatio)).deflate(_kOffScreenMargin);
2729+
final Rect bounds = (Offset.zero & (WidgetsBinding.instance.window.physicalSize / WidgetsBinding.instance.window.devicePixelRatio)).deflate(_kOffScreenMargin);
27332730
if (!bounds.contains(_lastPointerLocation!)) {
27342731
setState(() {
27352732
selection.clear();

0 commit comments

Comments
 (0)