Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
dfac9f9b
Commit
dfac9f9b
authored
Feb 27, 2016
by
Hixie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SizeObserver crusade: Remove SizeObserver
parent
b18047bf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
105 deletions
+0
-105
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+0
-28
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+0
-24
block_test.dart
packages/flutter/test/widget/block_test.dart
+0
-3
size_observer_test.dart
packages/flutter/test/widget/size_observer_test.dart
+0
-50
No files found.
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
dfac9f9b
...
...
@@ -5,7 +5,6 @@
import
'package:flutter/gestures.dart'
;
import
'package:vector_math/vector_math_64.dart'
;
import
'basic_types.dart'
;
import
'box.dart'
;
import
'debug.dart'
;
import
'object.dart'
;
...
...
@@ -1167,33 +1166,6 @@ class RenderFractionalTranslation extends RenderProxyBox {
}
}
/// Calls [onSizeChanged] whenever the child's layout size changes
///
/// Because size observer calls its callback during layout, you cannot modify
/// layout information during the callback.
class
RenderSizeObserver
extends
RenderProxyBox
{
RenderSizeObserver
({
this
.
onSizeChanged
,
RenderBox
child
})
:
super
(
child
)
{
assert
(
onSizeChanged
!=
null
);
}
/// The callback to call whenever the child's layout size changes
ValueChanged
<
Size
>
onSizeChanged
;
void
performLayout
()
{
Size
oldSize
=
hasSize
?
size
:
null
;
super
.
performLayout
();
if
(
oldSize
!=
size
)
{
// We make a copy of the Size object here because if we leak a _DebugSize
// object out of the render tree, we can get confused later if it comes
// back and gets set as the size property of a RenderBox.
onSizeChanged
(
new
Size
(
size
.
width
,
size
.
height
));
}
}
}
abstract
class
CustomPainter
{
const
CustomPainter
();
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
dfac9f9b
...
...
@@ -828,30 +828,6 @@ class Viewport extends OneChildRenderObjectWidget {
}
}
/// Calls [onSizeChanged] whenever the child's layout size changes
///
/// Because size observer calls its callback during layout, you cannot modify
/// layout information during the callback.
class
SizeObserver
extends
OneChildRenderObjectWidget
{
SizeObserver
({
Key
key
,
this
.
onSizeChanged
,
Widget
child
})
:
super
(
key:
key
,
child:
child
)
{
assert
(
onSizeChanged
!=
null
);
}
/// The callback to call whenever the child's layout size changes
final
ValueChanged
<
Size
>
onSizeChanged
;
RenderSizeObserver
createRenderObject
()
=>
new
RenderSizeObserver
(
onSizeChanged:
onSizeChanged
);
void
updateRenderObject
(
RenderSizeObserver
renderObject
,
SizeObserver
oldWidget
)
{
renderObject
.
onSizeChanged
=
onSizeChanged
;
}
void
didUnmountRenderObject
(
RenderSizeObserver
renderObject
)
{
renderObject
.
onSizeChanged
=
null
;
}
}
// CONTAINER
...
...
packages/flutter/test/widget/block_test.dart
View file @
dfac9f9b
...
...
@@ -22,7 +22,6 @@ void main() {
]
)
);
tester
.
pump
();
// for SizeObservers
Point
middleOfContainer
=
tester
.
getCenter
(
tester
.
findText
(
'Hello'
));
Point
target
=
tester
.
getCenter
(
tester
.
findElementByKey
(
blockKey
));
...
...
@@ -100,7 +99,6 @@ void main() {
}
tester
.
pumpWidget
(
buildBlock
(
ViewportAnchor
.
end
));
tester
.
pump
();
// for SizeObservers
Point
target
=
const
Point
(
200.0
,
200.0
);
tester
.
tapAt
(
target
);
...
...
@@ -108,7 +106,6 @@ void main() {
expect
(
second
,
equals
(
1
));
tester
.
pumpWidget
(
buildBlock
(
ViewportAnchor
.
start
));
tester
.
pump
();
// for SizeObservers
tester
.
tapAt
(
target
);
expect
(
first
,
equals
(
1
));
...
...
packages/flutter/test/widget/size_observer_test.dart
deleted
100644 → 0
View file @
b18047bf
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
test
(
'SizeObserver notices zero size'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
List
<
Size
>
results
=
<
Size
>[];
tester
.
pumpWidget
(
new
Center
(
child:
new
SizeObserver
(
onSizeChanged:
(
Size
size
)
{
results
.
add
(
size
);
},
child:
new
Container
(
width:
0.0
,
height:
0.0
)
)
));
expect
(
results
,
equals
([
Size
.
zero
]));
tester
.
pump
();
expect
(
results
,
equals
([
Size
.
zero
]));
tester
.
pumpWidget
(
new
Center
(
child:
new
SizeObserver
(
onSizeChanged:
(
Size
size
)
{
results
.
add
(
size
);
},
child:
new
Container
(
width:
100.0
,
height:
0.0
)
)
));
expect
(
results
,
equals
([
Size
.
zero
,
const
Size
(
100.0
,
0.0
)]));
tester
.
pump
();
expect
(
results
,
equals
([
Size
.
zero
,
const
Size
(
100.0
,
0.0
)]));
tester
.
pumpWidget
(
new
Center
(
child:
new
SizeObserver
(
onSizeChanged:
(
Size
size
)
{
results
.
add
(
size
);
},
child:
new
Container
(
width:
0.0
,
height:
0.0
)
)
));
expect
(
results
,
equals
([
Size
.
zero
,
const
Size
(
100.0
,
0.0
),
Size
.
zero
]));
tester
.
pump
();
expect
(
results
,
equals
([
Size
.
zero
,
const
Size
(
100.0
,
0.0
),
Size
.
zero
]));
tester
.
pumpWidget
(
new
Center
(
child:
new
SizeObserver
(
onSizeChanged:
(
Size
size
)
{
results
.
add
(
size
);
},
child:
new
Container
(
width:
0.0
,
height:
0.0
)
)
));
expect
(
results
,
equals
([
Size
.
zero
,
const
Size
(
100.0
,
0.0
),
Size
.
zero
]));
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment