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
4e89ccfd
Unverified
Commit
4e89ccfd
authored
Sep 15, 2020
by
Ayush Bherwani
Committed by
GitHub
Sep 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LayoutBuilder] Implements baseline logic to pass baseline to child (#65000)
parent
bcd0959a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
layout_builder.dart
packages/flutter/lib/src/widgets/layout_builder.dart
+7
-0
baseline_test.dart
packages/flutter/test/widgets/baseline_test.dart
+21
-1
No files found.
packages/flutter/lib/src/widgets/layout_builder.dart
View file @
4e89ccfd
...
...
@@ -361,6 +361,13 @@ class _RenderLayoutBuilder extends RenderBox with RenderObjectWithChildMixin<Ren
}
}
@override
double
computeDistanceToActualBaseline
(
TextBaseline
baseline
)
{
if
(
child
!=
null
)
return
child
.
getDistanceToActualBaseline
(
baseline
);
return
super
.
computeDistanceToActualBaseline
(
baseline
);
}
@override
bool
hitTestChildren
(
BoxHitTestResult
result
,
{
Offset
position
})
{
return
child
?.
hitTest
(
result
,
position:
position
)
??
false
;
...
...
packages/flutter/test/widgets/baseline_test.dart
View file @
4e89ccfd
...
...
@@ -93,6 +93,26 @@ void main() {
await
tester
.
pump
();
expect
(
calls
,
2
);
});
testWidgets
(
'LayoutBuilder returns child
\'
s baseline'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Baseline
(
baseline:
180.0
,
baselineType:
TextBaseline
.
alphabetic
,
child:
LayoutBuilder
(
builder:
(
BuildContext
context
,
BoxConstraints
constraints
)
{
return
BaselineDetector
(()
{});
},
),
),
),
),
);
expect
(
tester
.
getRect
(
find
.
byType
(
BaselineDetector
)).
top
,
160.0
);
});
}
class
BaselineDetector
extends
LeafRenderObjectWidget
{
...
...
@@ -133,7 +153,7 @@ class RenderBaselineDetector extends RenderBox {
double
computeDistanceToActualBaseline
(
TextBaseline
baseline
)
{
if
(
callback
!=
null
)
callback
();
return
0.0
;
return
2
0.0
;
}
void
dirty
()
{
...
...
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