Fixes: "FloatingActionButton.extended's isExtended property if false should show icon, not label" (#72431)
* Fix extended FAB with isExtended set to false showing both icon and label
This commit is contained in:
@@ -210,7 +210,11 @@ class FloatingActionButton extends StatelessWidget {
|
||||
label,
|
||||
const SizedBox(width: 20.0),
|
||||
]
|
||||
: <Widget>[
|
||||
: !isExtended ? <Widget>[
|
||||
const SizedBox(width: 20.0),
|
||||
icon,
|
||||
const SizedBox(width: 20.0),
|
||||
] : <Widget>[
|
||||
const SizedBox(width: 16.0),
|
||||
icon,
|
||||
const SizedBox(width: 8.0),
|
||||
|
||||
@@ -942,6 +942,27 @@ void main() {
|
||||
paints..circle(color: splashColor),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('extended FAB does not show label when isExtended is false', (WidgetTester tester) async {
|
||||
const Key iconKey = Key('icon');
|
||||
const Key labelKey = Key('label');
|
||||
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: FloatingActionButton.extended(
|
||||
isExtended: false,
|
||||
label: const Text('', key: labelKey),
|
||||
icon: const Icon(Icons.add, key: iconKey),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Verify that Icon is present and label is not.
|
||||
expect(find.byKey(iconKey), findsOneWidget);
|
||||
expect(find.byKey(labelKey), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
Offset _rightEdgeOfFab(WidgetTester tester) {
|
||||
|
||||
Reference in New Issue
Block a user