33// found in the LICENSE file.
44
55import 'dart:io' show Platform;
6- import 'dart:ui' as ui show FlutterView, Scene, SceneBuilder, SemanticsUpdate, ViewConstraints ;
6+ import 'dart:ui' as ui show FlutterView, Scene, SceneBuilder, SemanticsUpdate;
77
88import 'package:flutter/foundation.dart' ;
99import 'package:flutter/services.dart' ;
@@ -19,15 +19,14 @@ import 'object.dart';
1919class ViewConfiguration {
2020 /// Creates a view configuration.
2121 ///
22- /// By default, the view has [ViewConstraints] with all dimensions set to zero
23- /// (i.e. the view is forced to [Size.zero] ) and a [devicePixelRatio] of 1.0.
22+ /// By default, the view has zero [size] and a [devicePixelRatio] of 1.0.
2423 const ViewConfiguration ({
25- this .constraints = const ui. ViewConstraints (maxWidth : 0.0 , maxHeight : 0.0 ) ,
24+ this .size = Size .zero ,
2625 this .devicePixelRatio = 1.0 ,
2726 });
2827
29- /// The constraints of the output surface in logical pixel .
30- final ui. ViewConstraints constraints ;
28+ /// The size of the output surface.
29+ final Size size ;
3130
3231 /// The pixel density of the output surface.
3332 final double devicePixelRatio;
@@ -41,34 +40,21 @@ class ViewConfiguration {
4140 return Matrix4 .diagonal3Values (devicePixelRatio, devicePixelRatio, 1.0 );
4241 }
4342
44- /// Transforms the provided [Size] in logical pixels to physical pixels.
45- ///
46- /// The [FlutterView.render] method accepts only sizes in physical pixels,
47- /// but the framework operates in logical pixels. This method is used to
48- /// transform the logical size calculated for a [RenderView] back to a
49- /// physical size suitable to be passed to [FlutterView.render] .
50- ///
51- /// By default, this method just multiplies the provided [Size] with the
52- /// [devicePixelRatio] .
53- Size toPhysicalSize (Size logicalSize) {
54- return logicalSize * devicePixelRatio;
55- }
56-
5743 @override
5844 bool operator == (Object other) {
5945 if (other.runtimeType != runtimeType) {
6046 return false ;
6147 }
6248 return other is ViewConfiguration
63- && other.constraints == constraints
49+ && other.size == size
6450 && other.devicePixelRatio == devicePixelRatio;
6551 }
6652
6753 @override
68- int get hashCode => Object .hash (constraints , devicePixelRatio);
54+ int get hashCode => Object .hash (size , devicePixelRatio);
6955
7056 @override
71- String toString () => '$constraints at ${debugFormatDouble (devicePixelRatio )}x' ;
57+ String toString () => '$size at ${debugFormatDouble (devicePixelRatio )}x' ;
7258}
7359
7460/// The root of the render tree.
@@ -90,10 +76,8 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
9076 RenderBox ? child,
9177 ViewConfiguration ? configuration,
9278 required ui.FlutterView view,
93- }) : _view = view {
94- if (configuration != null ) {
95- this .configuration = configuration;
96- }
79+ }) : _configuration = configuration,
80+ _view = view {
9781 this .child = child;
9882 }
9983
@@ -121,7 +105,6 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
121105 }
122106 final ViewConfiguration ? oldConfiguration = _configuration;
123107 _configuration = value;
124- _constraints = BoxConstraints .fromViewConstraints (configuration.constraints);
125108 if (_rootTransform == null ) {
126109 // [prepareInitialFrame] has not been called yet, nothing to do for now.
127110 return ;
@@ -136,15 +119,6 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
136119 /// Whether a [configuration] has been set.
137120 bool get hasConfiguration => _configuration != null ;
138121
139- @override
140- BoxConstraints get constraints {
141- if (_constraints == null ) {
142- throw StateError ('Constraints are not available because RenderView has not been given a configuration yet.' );
143- }
144- return _constraints! ;
145- }
146- BoxConstraints ? _constraints;
147-
148122 /// The [FlutterView] into which this [RenderView] will render.
149123 ui.FlutterView get flutterView => _view;
150124 final ui.FlutterView _view;
@@ -214,13 +188,12 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
214188 @override
215189 void performLayout () {
216190 assert (_rootTransform != null );
217- final bool sizedByChild = ! constraints.isTight;
191+ _size = configuration.size;
192+ assert (_size.isFinite);
193+
218194 if (child != null ) {
219- child! .layout (constraints, parentUsesSize : sizedByChild );
195+ child! .layout (BoxConstraints . tight (_size) );
220196 }
221- _size = sizedByChild && child != null ? child! .size : constraints.smallest;
222- assert (size.isFinite);
223- assert (constraints.isSatisfiedBy (size));
224197 }
225198
226199 /// Determines the set of render objects located at the given position.
@@ -280,8 +253,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
280253 if (automaticSystemUiAdjustment) {
281254 _updateSystemChrome ();
282255 }
283- assert (configuration.constraints.isSatisfiedBy (size));
284- _view.render (scene, size: configuration.toPhysicalSize (size));
256+ _view.render (scene);
285257 scene.dispose ();
286258 assert (() {
287259 if (debugRepaintRainbowEnabled || debugRepaintTextRainbowEnabled) {
0 commit comments