Unverified Commit a11b21db authored by Kostia Sokolovskyi's avatar Kostia Sokolovskyi Committed by GitHub

ViewportOffset should dispatch creation in constructor. (#135420)

parent 9f4f6c47
...@@ -97,7 +97,11 @@ abstract class ViewportOffset extends ChangeNotifier { ...@@ -97,7 +97,11 @@ abstract class ViewportOffset extends ChangeNotifier {
/// Default constructor. /// Default constructor.
/// ///
/// Allows subclasses to construct this object directly. /// Allows subclasses to construct this object directly.
ViewportOffset(); ViewportOffset() {
if (kFlutterMemoryAllocationsEnabled) {
ChangeNotifier.maybeDispatchObjectCreation(this);
}
}
/// Creates a viewport offset with the given [pixels] value. /// Creates a viewport offset with the given [pixels] value.
/// ///
......
...@@ -1441,10 +1441,15 @@ void main() { ...@@ -1441,10 +1441,15 @@ void main() {
// Horizontal mismatch // Horizontal mismatch
expect( expect(
() { () {
final ViewportOffset verticalOffset = ViewportOffset.fixed(0.0);
addTearDown(verticalOffset.dispose);
final ViewportOffset horizontalOffset = ViewportOffset.fixed(0.0);
addTearDown(horizontalOffset.dispose);
SimpleBuilderTableViewport( SimpleBuilderTableViewport(
verticalOffset: ViewportOffset.fixed(0.0), verticalOffset: verticalOffset,
verticalAxisDirection: AxisDirection.left, verticalAxisDirection: AxisDirection.left,
horizontalOffset: ViewportOffset.fixed(0.0), horizontalOffset: horizontalOffset,
horizontalAxisDirection: AxisDirection.right, horizontalAxisDirection: AxisDirection.right,
delegate: builderDelegate, delegate: builderDelegate,
mainAxis: Axis.vertical, mainAxis: Axis.vertical,
...@@ -1462,10 +1467,15 @@ void main() { ...@@ -1462,10 +1467,15 @@ void main() {
// Vertical mismatch // Vertical mismatch
expect( expect(
() { () {
final ViewportOffset verticalOffset = ViewportOffset.fixed(0.0);
addTearDown(verticalOffset.dispose);
final ViewportOffset horizontalOffset = ViewportOffset.fixed(0.0);
addTearDown(horizontalOffset.dispose);
SimpleBuilderTableViewport( SimpleBuilderTableViewport(
verticalOffset: ViewportOffset.fixed(0.0), verticalOffset: verticalOffset,
verticalAxisDirection: AxisDirection.up, verticalAxisDirection: AxisDirection.up,
horizontalOffset: ViewportOffset.fixed(0.0), horizontalOffset: horizontalOffset,
horizontalAxisDirection: AxisDirection.down, horizontalAxisDirection: AxisDirection.down,
delegate: builderDelegate, delegate: builderDelegate,
mainAxis: Axis.vertical, mainAxis: Axis.vertical,
...@@ -1483,10 +1493,15 @@ void main() { ...@@ -1483,10 +1493,15 @@ void main() {
// Both // Both
expect( expect(
() { () {
final ViewportOffset verticalOffset = ViewportOffset.fixed(0.0);
addTearDown(verticalOffset.dispose);
final ViewportOffset horizontalOffset = ViewportOffset.fixed(0.0);
addTearDown(horizontalOffset.dispose);
SimpleBuilderTableViewport( SimpleBuilderTableViewport(
verticalOffset: ViewportOffset.fixed(0.0), verticalOffset: verticalOffset,
verticalAxisDirection: AxisDirection.left, verticalAxisDirection: AxisDirection.left,
horizontalOffset: ViewportOffset.fixed(0.0), horizontalOffset: horizontalOffset,
horizontalAxisDirection: AxisDirection.down, horizontalAxisDirection: AxisDirection.down,
delegate: builderDelegate, delegate: builderDelegate,
mainAxis: Axis.vertical, mainAxis: Axis.vertical,
...@@ -1548,10 +1563,15 @@ void main() { ...@@ -1548,10 +1563,15 @@ void main() {
// Horizontal mismatch // Horizontal mismatch
expect( expect(
() { () {
final ViewportOffset verticalOffset = ViewportOffset.fixed(0.0);
addTearDown(verticalOffset.dispose);
final ViewportOffset horizontalOffset = ViewportOffset.fixed(0.0);
addTearDown(horizontalOffset.dispose);
RenderSimpleBuilderTableViewport( RenderSimpleBuilderTableViewport(
verticalOffset: ViewportOffset.fixed(0.0), verticalOffset: verticalOffset,
verticalAxisDirection: AxisDirection.left, verticalAxisDirection: AxisDirection.left,
horizontalOffset: ViewportOffset.fixed(0.0), horizontalOffset: horizontalOffset,
horizontalAxisDirection: AxisDirection.right, horizontalAxisDirection: AxisDirection.right,
delegate: builderDelegate, delegate: builderDelegate,
mainAxis: Axis.vertical, mainAxis: Axis.vertical,
...@@ -1570,10 +1590,15 @@ void main() { ...@@ -1570,10 +1590,15 @@ void main() {
// Vertical mismatch // Vertical mismatch
expect( expect(
() { () {
final ViewportOffset verticalOffset = ViewportOffset.fixed(0.0);
addTearDown(verticalOffset.dispose);
final ViewportOffset horizontalOffset = ViewportOffset.fixed(0.0);
addTearDown(horizontalOffset.dispose);
RenderSimpleBuilderTableViewport( RenderSimpleBuilderTableViewport(
verticalOffset: ViewportOffset.fixed(0.0), verticalOffset: verticalOffset,
verticalAxisDirection: AxisDirection.up, verticalAxisDirection: AxisDirection.up,
horizontalOffset: ViewportOffset.fixed(0.0), horizontalOffset: horizontalOffset,
horizontalAxisDirection: AxisDirection.down, horizontalAxisDirection: AxisDirection.down,
delegate: builderDelegate, delegate: builderDelegate,
mainAxis: Axis.vertical, mainAxis: Axis.vertical,
...@@ -1592,10 +1617,15 @@ void main() { ...@@ -1592,10 +1617,15 @@ void main() {
// Both // Both
expect( expect(
() { () {
final ViewportOffset verticalOffset = ViewportOffset.fixed(0.0);
addTearDown(verticalOffset.dispose);
final ViewportOffset horizontalOffset = ViewportOffset.fixed(0.0);
addTearDown(horizontalOffset.dispose);
RenderSimpleBuilderTableViewport( RenderSimpleBuilderTableViewport(
verticalOffset: ViewportOffset.fixed(0.0), verticalOffset: verticalOffset,
verticalAxisDirection: AxisDirection.left, verticalAxisDirection: AxisDirection.left,
horizontalOffset: ViewportOffset.fixed(0.0), horizontalOffset: horizontalOffset,
horizontalAxisDirection: AxisDirection.down, horizontalAxisDirection: AxisDirection.down,
delegate: builderDelegate, delegate: builderDelegate,
mainAxis: Axis.vertical, mainAxis: Axis.vertical,
...@@ -1622,10 +1652,15 @@ void main() { ...@@ -1622,10 +1652,15 @@ void main() {
} }
); );
addTearDown(delegate.dispose); addTearDown(delegate.dispose);
final ViewportOffset verticalOffset = ViewportOffset.fixed(10.0);
addTearDown(verticalOffset.dispose);
final ViewportOffset horizontalOffset = ViewportOffset.fixed(20.0);
addTearDown(horizontalOffset.dispose);
final RenderSimpleBuilderTableViewport renderViewport = RenderSimpleBuilderTableViewport( final RenderSimpleBuilderTableViewport renderViewport = RenderSimpleBuilderTableViewport(
verticalOffset: ViewportOffset.fixed(10.0), verticalOffset: verticalOffset,
verticalAxisDirection: AxisDirection.down, verticalAxisDirection: AxisDirection.down,
horizontalOffset: ViewportOffset.fixed(20.0), horizontalOffset: horizontalOffset,
horizontalAxisDirection: AxisDirection.right, horizontalAxisDirection: AxisDirection.right,
delegate: delegate, delegate: delegate,
mainAxis: Axis.vertical, mainAxis: Axis.vertical,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment