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

Commit

Permalink
Revert "Remove single-view assumption from widgets library (#117480)"…
Browse files Browse the repository at this point in the history
… (#117545)

This reverts commit b8b3567.
  • Loading branch information
goderbauer authored Dec 22, 2022
1 parent 95ff839 commit b8d5d9c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
10 changes: 4 additions & 6 deletions packages/flutter/lib/src/widgets/editable_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import 'text_editing_intents.dart';
import 'text_selection.dart';
import 'text_selection_toolbar_anchors.dart';
import 'ticker_provider.dart';
import 'view.dart';
import 'widget_span.dart';

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

@override
void didChangeMetrics() {
final ui.FlutterView view = View.of(context);
if (_lastBottomViewInset != view.viewInsets.bottom) {
if (_lastBottomViewInset != WidgetsBinding.instance.window.viewInsets.bottom) {
SchedulerBinding.instance.addPostFrameCallback((Duration _) {
_selectionOverlay?.updateForScroll();
});
if (_lastBottomViewInset < view.viewInsets.bottom) {
if (_lastBottomViewInset < WidgetsBinding.instance.window.viewInsets.bottom) {
// Because the metrics change signal from engine will come here every frame
// (on both iOS and Android). So we don't need to show caret with animation.
_scheduleShowCaretOnScreen(withAnimation: false);
}
}
_lastBottomViewInset = view.viewInsets.bottom;
_lastBottomViewInset = WidgetsBinding.instance.window.viewInsets.bottom;
}

Future<void> _performSpellCheck(final String text) async {
Expand Down Expand Up @@ -3518,7 +3516,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
if (_hasFocus) {
// Listen for changing viewInsets, which indicates keyboard showing up.
WidgetsBinding.instance.addObserver(this);
_lastBottomViewInset = View.of(context).viewInsets.bottom;
_lastBottomViewInset = WidgetsBinding.instance.window.viewInsets.bottom;
if (!widget.readOnly) {
_scheduleShowCaretOnScreen(withAnimation: true);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/flutter/lib/src/widgets/scroll_physics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'framework.dart';
import 'overscroll_indicator.dart';
import 'scroll_metrics.dart';
import 'scroll_simulation.dart';
import 'view.dart';

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

Expand Down Expand Up @@ -252,7 +251,7 @@ class ScrollPhysics {
assert(metrics != null);
assert(context != null);
if (parent == null) {
final double maxPhysicalPixels = View.of(context).physicalSize.longestSide;
final double maxPhysicalPixels = WidgetsBinding.instance.window.physicalSize.longestSide;
return velocity.abs() > maxPhysicalPixels;
}
return parent!.recommendDeferredLoading(velocity, metrics, context);
Expand Down
5 changes: 2 additions & 3 deletions packages/flutter/lib/src/widgets/semantics_debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'basic.dart';
import 'binding.dart';
import 'framework.dart';
import 'gesture_detector.dart';
import 'view.dart';

/// A widget that visualizes the semantics for the child.
///
Expand Down Expand Up @@ -97,7 +96,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi
Offset? _lastPointerDownLocation;
void _handlePointerDown(PointerDownEvent event) {
setState(() {
_lastPointerDownLocation = event.position * View.of(context).devicePixelRatio;
_lastPointerDownLocation = event.position * WidgetsBinding.instance.window.devicePixelRatio;
});
// TODO(ianh): Use a gesture recognizer so that we can reset the
// _lastPointerDownLocation when none of the other gesture recognizers win.
Expand Down Expand Up @@ -160,7 +159,7 @@ class _SemanticsDebuggerState extends State<SemanticsDebugger> with WidgetsBindi
_pipelineOwner,
_client.generation,
_lastPointerDownLocation, // in physical pixels
View.of(context).devicePixelRatio,
WidgetsBinding.instance.window.devicePixelRatio,
widget.labelStyle,
),
child: GestureDetector(
Expand Down
5 changes: 1 addition & 4 deletions packages/flutter/lib/src/widgets/widget_inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'dart:math' as math;
import 'dart:ui' as ui
show
ClipOp,
FlutterView,
Image,
ImageByteFormat,
Paragraph,
Expand All @@ -31,7 +30,6 @@ import 'debug.dart';
import 'framework.dart';
import 'gesture_detector.dart';
import 'service_extensions.dart';
import 'view.dart';

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

0 comments on commit b8d5d9c

Please sign in to comment.