-
Notifications
You must be signed in to change notification settings - Fork 6k
Remove single view assumptions from window.dart
#38453
Changes from all commits
5f9cbb0
1f5376a
def8a49
ee1d3a3
59a1b34
559ab5c
3ef5f40
368ec15
570cc18
109c396
b08531d
d8425c2
6a8fd2e
4c659b1
48832da
9504d93
bdb74d2
4453c99
5103c3a
184e658
864a0ee
0ae4700
56e558c
278f724
ce6db62
23be98b
40922b5
75d1cbe
e8df09f
0209cf6
ec25975
8199e72
b3164c8
d42d9ec
5c2e0a9
12d4871
15ebe59
1f71e01
6d531ba
3a70482
2a4f807
9f4ac26
b2b410e
4bbd09d
82defe4
8fa153b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,10 +222,10 @@ class PlatformDispatcher { | |
final ViewConfiguration previousConfiguration = | ||
_viewConfigurations[id] ?? const ViewConfiguration(); | ||
if (!_views.containsKey(id)) { | ||
_views[id] = FlutterWindow._(id, this); | ||
_views[id] = FlutterView._(id, this); | ||
} | ||
_viewConfigurations[id] = previousConfiguration.copyWith( | ||
window: _views[id], | ||
view: _views[id], | ||
devicePixelRatio: devicePixelRatio, | ||
geometry: Rect.fromLTWH(0.0, 0.0, width, height), | ||
viewPadding: WindowPadding._( | ||
|
@@ -1289,8 +1289,18 @@ class PlatformConfiguration { | |
/// An immutable view configuration. | ||
class ViewConfiguration { | ||
/// A const constructor for an immutable [ViewConfiguration]. | ||
/// | ||
/// When constructing a view configuration, supply either the [view] or the | ||
/// [window] property, but not both since the [view] and [window] property | ||
/// are backed by the same instance variable. | ||
const ViewConfiguration({ | ||
this.window, | ||
FlutterView? view, | ||
@Deprecated(''' | ||
goderbauer marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ultimately, it's up to you, but I would probably do the rename (with deprecation) in a separate PR that's dedicated to just that. That may make it easier to land these two changes and potentially roll back if there are issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds like a good idea. I'd like to address all the feedback and get an LGTM before I cherry-pick the commits from this PR into another one. |
||
Use the `view` property instead. | ||
This change is related to adding multi-view support in Flutter. | ||
This feature was deprecated after 3.7.0-1.2.pre. | ||
''') | ||
FlutterView? window, | ||
this.devicePixelRatio = 1.0, | ||
this.geometry = Rect.zero, | ||
this.visible = false, | ||
|
@@ -1300,10 +1310,17 @@ class ViewConfiguration { | |
this.padding = WindowPadding.zero, | ||
this.gestureSettings = const GestureSettings(), | ||
this.displayFeatures = const <DisplayFeature>[], | ||
}); | ||
}) : assert(window == null || view == null), | ||
_view = view ?? window; | ||
|
||
/// Copy this configuration with some fields replaced. | ||
ViewConfiguration copyWith({ | ||
FlutterView? view, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deprecate the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
@Deprecated(''' | ||
Use the `view` property instead. | ||
This change is related to adding multi-view support in Flutter. | ||
This feature was deprecated after 3.7.0-1.2.pre. | ||
''') | ||
FlutterView? window, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. copy with should do something with the window property instead of silently ignoring it. |
||
double? devicePixelRatio, | ||
Rect? geometry, | ||
|
@@ -1315,8 +1332,9 @@ class ViewConfiguration { | |
GestureSettings? gestureSettings, | ||
List<DisplayFeature>? displayFeatures, | ||
}) { | ||
assert(view == null || window == null); | ||
return ViewConfiguration( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should probably assert that at least one of window, view is null There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added 7d2ad3e. |
||
window: window ?? this.window, | ||
view: view ?? window ?? _view, | ||
devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio, | ||
geometry: geometry ?? this.geometry, | ||
visible: visible ?? this.visible, | ||
|
@@ -1329,11 +1347,22 @@ class ViewConfiguration { | |
); | ||
} | ||
|
||
/// The top level view into which the view is placed and its geometry is | ||
/// relative to. | ||
/// The top level view for which this [ViewConfiguration]'s properties apply to. | ||
/// | ||
/// If this property is null, this [ViewConfiguration] is a top level view. | ||
@Deprecated(''' | ||
Use the `view` property instead. | ||
This change is related to adding multi-view support in Flutter. | ||
This feature was deprecated after 3.7.0-1.2.pre. | ||
''') | ||
FlutterView? get window => _view; | ||
|
||
/// The top level view for which this [ViewConfiguration]'s properties apply to. | ||
/// | ||
/// If null, then this configuration represents a top level view itself. | ||
final FlutterView? window; | ||
/// If this property is null, this [ViewConfiguration] is a top level view. | ||
FlutterView? get view => _view; | ||
dkwingsmt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
final FlutterView? _view; | ||
|
||
/// The pixel density of the output surface. | ||
final double devicePixelRatio; | ||
|
@@ -1427,7 +1456,7 @@ class ViewConfiguration { | |
|
||
@override | ||
String toString() { | ||
return '$runtimeType[window: $window, geometry: $geometry]'; | ||
return '$runtimeType[view: $view, geometry: $geometry]'; | ||
} | ||
} | ||
|
||
|
@@ -1666,7 +1695,7 @@ enum AppLifecycleState { | |
/// On Android, this corresponds to an app or the Flutter host view running | ||
/// in the foreground inactive state. Apps transition to this state when | ||
/// another activity is focused, such as a split-screen app, a phone call, | ||
/// a picture-in-picture app, a system dialog, or another window. | ||
/// a picture-in-picture app, a system dialog, or another view. | ||
/// | ||
/// Apps in this state should assume that they may be [paused] at any time. | ||
inactive, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,7 +190,13 @@ class PlatformConfiguration { | |
|
||
class ViewConfiguration { | ||
const ViewConfiguration({ | ||
this.window, | ||
FlutterView? view, | ||
@Deprecated(''' | ||
Use the `view` property instead. | ||
This change is related to adding multi-view support in Flutter. | ||
This feature was deprecated after 3.7.0-1.2.pre. | ||
''') | ||
FlutterView? window, | ||
this.devicePixelRatio = 1.0, | ||
this.geometry = Rect.zero, | ||
this.visible = false, | ||
|
@@ -200,10 +206,17 @@ class ViewConfiguration { | |
this.padding = WindowPadding.zero, | ||
this.gestureSettings = const GestureSettings(), | ||
this.displayFeatures = const <DisplayFeature>[], | ||
}); | ||
}) : assert(window == null || view == null), | ||
_view = view ?? window; | ||
|
||
ViewConfiguration copyWith({ | ||
FlutterWindow? window, | ||
FlutterView? view, | ||
@Deprecated(''' | ||
Use the `view` property instead. | ||
This change is related to adding multi-view support in Flutter. | ||
This feature was deprecated after 3.7.0-1.2.pre. | ||
''') | ||
FlutterView? window, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deprecate window param? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
double? devicePixelRatio, | ||
Rect? geometry, | ||
bool? visible, | ||
|
@@ -214,8 +227,9 @@ class ViewConfiguration { | |
GestureSettings? gestureSettings, | ||
List<DisplayFeature>? displayFeatures, | ||
}) { | ||
assert(view == null || window == null); | ||
return ViewConfiguration( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assert here that at most of view, window is not-null. |
||
window: window ?? this.window, | ||
view: view ?? window ?? _view, | ||
devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio, | ||
geometry: geometry ?? this.geometry, | ||
visible: visible ?? this.visible, | ||
|
@@ -228,7 +242,14 @@ class ViewConfiguration { | |
); | ||
} | ||
|
||
final FlutterWindow? window; | ||
@Deprecated(''' | ||
Use the `view` property instead. | ||
This change is related to adding multi-view support in Flutter. | ||
This feature was deprecated after 3.7.0-1.2.pre. | ||
''') | ||
FlutterView? get window => _view; | ||
FlutterView? get view => _view; | ||
final FlutterView? _view; | ||
final double devicePixelRatio; | ||
final Rect geometry; | ||
final bool visible; | ||
|
@@ -241,7 +262,7 @@ class ViewConfiguration { | |
|
||
@override | ||
String toString() { | ||
return '$runtimeType[window: $window, geometry: $geometry]'; | ||
return '$runtimeType[view: $view, geometry: $geometry]'; | ||
} | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.