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
0265cb68
Commit
0265cb68
authored
Dec 23, 2019
by
Chen Yumin
Committed by
Justin McCandless
Dec 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tab's icon margin configurable (Fix #47363) (#47364)
Adds the `iconMargin` parameter to Tab
parent
f2f9d0e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+11
-2
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+24
-0
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
0265cb68
...
...
@@ -60,11 +60,14 @@ class Tab extends StatelessWidget {
/// Creates a material design [TabBar] tab.
///
/// At least one of [text], [icon], and [child] must be non-null. The [text]
/// and [child] arguments must not be used at the same time.
/// and [child] arguments must not be used at the same time. The
/// [iconMargin] is only useful when [icon] and either one of [text] or
/// [child] is non-null.
const
Tab
({
Key
key
,
this
.
text
,
this
.
icon
,
this
.
iconMargin
=
const
EdgeInsets
.
only
(
bottom:
10.0
),
this
.
child
,
})
:
assert
(
text
!=
null
||
child
!=
null
||
icon
!=
null
),
assert
(!(
text
!=
null
&&
null
!=
child
)),
// TODO(goderbauer): https://github.com/dart-lang/sdk/issues/34180
...
...
@@ -85,6 +88,12 @@ class Tab extends StatelessWidget {
/// An icon to display as the tab's label.
final
Widget
icon
;
/// The margin added around the tab's icon.
///
/// Only useful when used in combination with [icon], and either one of
/// [text] or [child] is non-null.
final
EdgeInsetsGeometry
iconMargin
;
Widget
_buildLabelText
()
{
return
child
??
Text
(
text
,
softWrap:
false
,
overflow:
TextOverflow
.
fade
);
}
...
...
@@ -109,7 +118,7 @@ class Tab extends StatelessWidget {
children:
<
Widget
>[
Container
(
child:
icon
,
margin:
const
EdgeInsets
.
only
(
bottom:
10.0
)
,
margin:
iconMargin
,
),
_buildLabelText
(),
],
...
...
packages/flutter/test/material/tabs_test.dart
View file @
0265cb68
...
...
@@ -254,6 +254,30 @@ void main() {
expect
(
tester
.
getSize
(
find
.
byType
(
Tab
)),
const
Size
(
14.0
,
72.0
));
},
skip:
isBrowser
);
testWidgets
(
'Tab sizing - icon, iconMargin and text'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
fontFamily:
'Ahem'
),
home:
const
Center
(
child:
Material
(
child:
Tab
(
icon:
SizedBox
(
width:
10.0
,
height:
10.0
,
),
iconMargin:
EdgeInsets
.
symmetric
(
horizontal:
100.0
,
),
text:
'x'
,
),
),
),
),
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
byType
(
RichText
)).
text
.
style
.
fontFamily
,
'Ahem'
);
expect
(
tester
.
getSize
(
find
.
byType
(
Tab
)),
const
Size
(
210.0
,
72.0
));
},
skip:
isBrowser
);
testWidgets
(
'Tab sizing - icon and child'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
fontFamily:
'Ahem'
),
home:
const
Center
(
child:
Material
(
child:
Tab
(
icon:
SizedBox
(
width:
10.0
,
height:
10.0
),
child:
Text
(
'x'
))))),
...
...
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