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
0f218e42
Commit
0f218e42
authored
Feb 22, 2019
by
ocavue
Committed by
Hans Muller
Feb 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make extended FAB's icon optional (#27711)
parent
97b11358
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
11 deletions
+60
-11
floating_action_button.dart
...ages/flutter/lib/src/material/floating_action_button.dart
+17
-11
floating_action_button_test.dart
...es/flutter/test/material/floating_action_button_test.dart
+43
-0
No files found.
packages/flutter/lib/src/material/floating_action_button.dart
View file @
0f218e42
...
...
@@ -92,10 +92,10 @@ class FloatingActionButton extends StatelessWidget {
disabledElevation
=
disabledElevation
??
elevation
,
super
(
key:
key
);
/// Creates a wider [StadiumBorder]-shaped floating action button with
both
/// an [icon] and a [label].
/// Creates a wider [StadiumBorder]-shaped floating action button with
/// an
optional
[icon] and a [label].
///
/// The [label], [
icon], [
elevation], [highlightElevation], [clipBehavior] and
/// The [label], [elevation], [highlightElevation], [clipBehavior] and
/// [shape] arguments must not be null. Additionally, [elevation]
/// [highlightElevation], and [disabledElevation] (if specified) must be
/// non-negative.
...
...
@@ -113,7 +113,7 @@ class FloatingActionButton extends StatelessWidget {
this
.
isExtended
=
true
,
this
.
materialTapTargetSize
,
this
.
clipBehavior
=
Clip
.
none
,
@required
Widget
icon
,
Widget
icon
,
@required
Widget
label
,
})
:
assert
(
elevation
!=
null
&&
elevation
>=
0.0
),
assert
(
highlightElevation
!=
null
&&
highlightElevation
>=
0.0
),
...
...
@@ -127,13 +127,19 @@ class FloatingActionButton extends StatelessWidget {
child
=
_ChildOverflowBox
(
child:
Row
(
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
const
SizedBox
(
width:
16.0
),
icon
,
const
SizedBox
(
width:
8.0
),
label
,
const
SizedBox
(
width:
20.0
),
],
children:
icon
==
null
?
<
Widget
>[
const
SizedBox
(
width:
20.0
),
label
,
const
SizedBox
(
width:
20.0
),
]
:
<
Widget
>[
const
SizedBox
(
width:
16.0
),
icon
,
const
SizedBox
(
width:
8.0
),
label
,
const
SizedBox
(
width:
20.0
),
],
),
),
super
(
key:
key
);
...
...
packages/flutter/test/material/floating_action_button_test.dart
View file @
0f218e42
...
...
@@ -338,6 +338,49 @@ void main() {
expect
(
tester
.
getSize
(
fabFinder
).
width
,
168
);
});
testWidgets
(
'FloatingActionButton.isExtended (without icon)'
,
(
WidgetTester
tester
)
async
{
final
Finder
fabFinder
=
find
.
byType
(
FloatingActionButton
);
FloatingActionButton
getFabWidget
()
{
return
tester
.
widget
<
FloatingActionButton
>(
fabFinder
);
}
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
floatingActionButton:
FloatingActionButton
.
extended
(
label:
const
SizedBox
(
width:
100.0
,
child:
Text
(
'label'
),
),
onPressed:
null
,
),
),
),
);
expect
(
getFabWidget
().
isExtended
,
true
);
expect
(
getFabWidget
().
shape
,
const
StadiumBorder
());
expect
(
find
.
text
(
'label'
),
findsOneWidget
);
expect
(
find
.
byType
(
Icon
),
findsNothing
);
// Verify that the widget's height is 48 and that its internal
/// horizontal layout is: 20 label 20
expect
(
tester
.
getSize
(
fabFinder
).
height
,
48.0
);
final
double
fabLeft
=
tester
.
getTopLeft
(
fabFinder
).
dx
;
final
double
fabRight
=
tester
.
getTopRight
(
fabFinder
).
dx
;
final
double
labelLeft
=
tester
.
getTopLeft
(
find
.
text
(
'label'
)).
dx
;
final
double
labelRight
=
tester
.
getTopRight
(
find
.
text
(
'label'
)).
dx
;
expect
(
labelLeft
-
fabLeft
,
20.0
);
expect
(
fabRight
-
labelRight
,
20.0
);
// The overall width of the button is:
// 140 = 20 + 100(label) + 20
expect
(
tester
.
getSize
(
find
.
text
(
'label'
)).
width
,
100.0
);
expect
(
tester
.
getSize
(
fabFinder
).
width
,
140
);
});
testWidgets
(
'Floating Action Button heroTag'
,
(
WidgetTester
tester
)
async
{
BuildContext
theContext
;
await
tester
.
pumpWidget
(
...
...
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