Unverified Commit af9f2104 authored by rami-a's avatar rami-a Committed by GitHub

Fix single action banner to ensure button alignment (#39583)

parent 72cacb40
...@@ -143,7 +143,7 @@ class MaterialBanner extends StatelessWidget { ...@@ -143,7 +143,7 @@ class MaterialBanner extends StatelessWidget {
padding: leadingPadding, padding: leadingPadding,
child: leading, child: leading,
), ),
Flexible( Expanded(
child: DefaultTextStyle( child: DefaultTextStyle(
style: textStyle, style: textStyle,
child: content, child: content,
......
...@@ -100,6 +100,51 @@ void main() { ...@@ -100,6 +100,51 @@ void main() {
expect(contentBottomLeft.dx, lessThan(actionsTopRight.dx)); expect(contentBottomLeft.dx, lessThan(actionsTopRight.dx));
}); });
// Regression test for https://github.com/flutter/flutter/issues/39574
testWidgets('Single action laid out beside content but aligned to the trailing edge', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: MaterialBanner(
content: const Text('Content'),
actions: <Widget>[
FlatButton(
child: const Text('Action'),
onPressed: () { },
),
],
),
),
);
final Offset actionsTopRight = tester.getTopRight(find.byType(ButtonBar));
final Offset bannerTopRight = tester.getTopRight(find.byType(MaterialBanner));
expect(actionsTopRight.dx, bannerTopRight.dx);
});
// Regression test for https://github.com/flutter/flutter/issues/39574
testWidgets('Single action laid out beside content but aligned to the trailing edge - RTL', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Directionality(
textDirection: TextDirection.rtl,
child: MaterialBanner(
content: const Text('Content'),
actions: <Widget>[
FlatButton(
child: const Text('Action'),
onPressed: () { },
),
],
),
),
),
);
final Offset actionsTopLeft = tester.getTopLeft(find.byType(ButtonBar));
final Offset bannerTopLeft = tester.getTopLeft(find.byType(MaterialBanner));
expect(actionsTopLeft.dx, bannerTopLeft.dx);
});
testWidgets('Actions laid out below content if forced override', (WidgetTester tester) async { testWidgets('Actions laid out below content if forced override', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment