diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/buttons_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/buttons_demo.dart index 5b3525225e..d19527e9ad 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/buttons_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/buttons_demo.dart @@ -127,8 +127,9 @@ class _ButtonsDemoState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - ButtonBar( - mainAxisSize: MainAxisSize.min, + const SizedBox(height: 2), + OverflowBar( + spacing: 8, children: [ ElevatedButton( style: style, @@ -143,8 +144,9 @@ class _ButtonsDemoState extends State { ), ], ), - ButtonBar( - mainAxisSize: MainAxisSize.min, + const SizedBox(height: 16), + OverflowBar( + spacing: 8, children: [ ElevatedButton.icon( style: style, @@ -174,8 +176,9 @@ class _ButtonsDemoState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - ButtonBar( - mainAxisSize: MainAxisSize.min, + const SizedBox(height: 2), + OverflowBar( + spacing: 8, children: [ TextButton( style: style, @@ -190,8 +193,8 @@ class _ButtonsDemoState extends State { ), ], ), - ButtonBar( - mainAxisSize: MainAxisSize.min, + OverflowBar( + spacing: 8, children: [ TextButton.icon( style: style, @@ -221,8 +224,9 @@ class _ButtonsDemoState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - ButtonBar( - mainAxisSize: MainAxisSize.min, + const SizedBox(height: 2), + OverflowBar( + spacing: 8, children: [ OutlinedButton( style: style, @@ -238,8 +242,9 @@ class _ButtonsDemoState extends State { ), ], ), - ButtonBar( - mainAxisSize: MainAxisSize.min, + const SizedBox(height: 16), + OverflowBar( + spacing: 8, children: [ OutlinedButton.icon( style: style, diff --git a/dev/integration_tests/flutter_gallery/lib/demo/material/cards_demo.dart b/dev/integration_tests/flutter_gallery/lib/demo/material/cards_demo.dart index 78e08bf389..f640f7eb00 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/material/cards_demo.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/material/cards_demo.dart @@ -314,20 +314,24 @@ class TravelDestinationContent extends StatelessWidget { ), if (destination.type == CardDemoType.standard) // share, explore buttons - ButtonBar( - alignment: MainAxisAlignment.start, - children: [ - TextButton( - style: textButtonStyle, - onPressed: () { print('pressed'); }, - child: Text('SHARE', semanticsLabel: 'Share ${destination.title}'), - ), - TextButton( - style: textButtonStyle, - onPressed: () { print('pressed'); }, - child: Text('EXPLORE', semanticsLabel: 'Explore ${destination.title}'), - ), - ], + Padding( + padding: const EdgeInsetsDirectional.only(start: 8, top: 8), + child: OverflowBar( + alignment: MainAxisAlignment.start, + spacing: 8, + children: [ + TextButton( + style: textButtonStyle, + onPressed: () { print('pressed'); }, + child: Text('SHARE', semanticsLabel: 'Share ${destination.title}'), + ), + TextButton( + style: textButtonStyle, + onPressed: () { print('pressed'); }, + child: Text('EXPLORE', semanticsLabel: 'Explore ${destination.title}'), + ), + ], + ), ), ], ); diff --git a/dev/integration_tests/flutter_gallery/lib/demo/shrine/login.dart b/dev/integration_tests/flutter_gallery/lib/demo/shrine/login.dart index 95437a40f7..0022f03e66 100644 --- a/dev/integration_tests/flutter_gallery/lib/demo/shrine/login.dart +++ b/dev/integration_tests/flutter_gallery/lib/demo/shrine/login.dart @@ -82,38 +82,37 @@ class _LoginPageState extends State { ), ), ), - Wrap( + const SizedBox(height: 12.0), + OverflowBar( + spacing: 8, + alignment: MainAxisAlignment.end, children: [ - ButtonBar( - children: [ - TextButton( - style: TextButton.styleFrom( - shape: const BeveledRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(7.0)), - ), - ), - onPressed: () { - // The login screen is immediately displayed on top of - // the Shrine home screen using onGenerateRoute and so - // rootNavigator must be set to true in order to get out - // of Shrine completely. - Navigator.of(context, rootNavigator: true).pop(); - }, - child: const Text('CANCEL'), + TextButton( + style: TextButton.styleFrom( + shape: const BeveledRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(7.0)), ), - ElevatedButton( - style: ElevatedButton.styleFrom( - elevation: 8.0, - shape: const BeveledRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(7.0)), - ), - ), - onPressed: () { - Navigator.pop(context); - }, - child: const Text('NEXT'), + ), + onPressed: () { + // The login screen is immediately displayed on top of + // the Shrine home screen using onGenerateRoute and so + // rootNavigator must be set to true in order to get out + // of Shrine completely. + Navigator.of(context, rootNavigator: true).pop(); + }, + child: const Text('CANCEL'), + ), + ElevatedButton( + style: ElevatedButton.styleFrom( + elevation: 8.0, + shape: const BeveledRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(7.0)), ), - ], + ), + onPressed: () { + Navigator.pop(context); + }, + child: const Text('NEXT'), ), ], ), diff --git a/dev/integration_tests/flutter_gallery/test/demo/material/buttons_demo_test.dart b/dev/integration_tests/flutter_gallery/test/demo/material/buttons_demo_test.dart new file mode 100644 index 0000000000..a219331609 --- /dev/null +++ b/dev/integration_tests/flutter_gallery/test/demo/material/buttons_demo_test.dart @@ -0,0 +1,44 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_gallery/demo/material/buttons_demo.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('Button locations are OK', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/pull/85351 + { + await tester.pumpWidget(const MaterialApp(home: ButtonsDemo())); + expect(find.byType(ElevatedButton).evaluate().length, 2); + final Offset topLeft1 = tester.getTopLeft(find.byType(ElevatedButton).first); + final Offset topLeft2 = tester.getTopLeft(find.byType(ElevatedButton).last); + expect(topLeft1.dx, 203); + expect(topLeft2.dx, 453); + expect(topLeft1.dy, topLeft2.dy); + } + + { + await tester.tap(find.text('TEXT')); + await tester.pumpAndSettle(); + expect(find.byType(TextButton).evaluate().length, 2); + final Offset topLeft1 = tester.getTopLeft(find.byType(TextButton).first); + final Offset topLeft2 = tester.getTopLeft(find.byType(TextButton).last); + expect(topLeft1.dx, 247); + expect(topLeft2.dx, 425); + expect(topLeft1.dy, topLeft2.dy); + } + + { + await tester.tap(find.text('OUTLINED')); + await tester.pumpAndSettle(); + expect(find.byType(OutlinedButton).evaluate().length, 2); + final Offset topLeft1 = tester.getTopLeft(find.byType(OutlinedButton).first); + final Offset topLeft2 = tester.getTopLeft(find.byType(OutlinedButton).last); + expect(topLeft1.dx, 203); + expect(topLeft2.dx, 453); + expect(topLeft1.dy, topLeft2.dy); + } + }); +}