Unverified Commit 890e6cce authored by Hans Muller's avatar Hans Muller Committed by GitHub

Replaced obsolete use of FlatButton with TextButton (#66597)

parent db6e2d8a
...@@ -11,15 +11,14 @@ import 'package:flutter/scheduler.dart'; ...@@ -11,15 +11,14 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'button_theme.dart';
import 'colors.dart'; import 'colors.dart';
import 'constants.dart'; import 'constants.dart';
import 'debug.dart'; import 'debug.dart';
import 'flat_button.dart';
import 'icon_button.dart'; import 'icon_button.dart';
import 'icons.dart'; import 'icons.dart';
import 'material.dart'; import 'material.dart';
import 'material_localizations.dart'; import 'material_localizations.dart';
import 'text_button.dart';
import 'text_selection_theme.dart'; import 'text_selection_theme.dart';
import 'theme.dart'; import 'theme.dart';
...@@ -84,22 +83,26 @@ class _TextSelectionToolbarState extends State<_TextSelectionToolbar> with Ticke ...@@ -84,22 +83,26 @@ class _TextSelectionToolbarState extends State<_TextSelectionToolbar> with Ticke
Widget _getItem(_ItemData itemData, bool isFirst, bool isLast) { Widget _getItem(_ItemData itemData, bool isFirst, bool isLast) {
assert(isFirst != null); assert(isFirst != null);
assert(isLast != null); assert(isLast != null);
return ButtonTheme.fromButtonThemeData(
data: ButtonTheme.of(context).copyWith( // TODO(hansmuller): Should be colorScheme.onSurface
height: kMinInteractiveDimension, final ThemeData theme = Theme.of(context);
minWidth: kMinInteractiveDimension, final bool isDark = theme.colorScheme.brightness == Brightness.dark;
), final Color primary = isDark ? Colors.white : Colors.black87;
child: FlatButton(
onPressed: itemData.onPressed, return TextButton(
style: TextButton.styleFrom(
primary: primary,
shape: const RoundedRectangleBorder(),
minimumSize: const Size(kMinInteractiveDimension, kMinInteractiveDimension),
padding: EdgeInsets.only( padding: EdgeInsets.only(
// These values were eyeballed to match the native text selection menu // These values were eyeballed to match the native text selection menu
// on a Pixel 2 running Android 10. // on a Pixel 2 running Android 10.
left: 9.5 + (isFirst ? 5.0 : 0.0), left: 9.5 + (isFirst ? 5.0 : 0.0),
right: 9.5 + (isLast ? 5.0 : 0.0), right: 9.5 + (isLast ? 5.0 : 0.0),
), ),
shape: Border.all(width: 0.0, color: Colors.transparent),
child: Text(itemData.label),
), ),
onPressed: itemData.onPressed,
child: Text(itemData.label),
); );
} }
......
...@@ -6172,7 +6172,7 @@ void main() { ...@@ -6172,7 +6172,7 @@ void main() {
); );
// But don't trigger the toolbar. // But don't trigger the toolbar.
expect(find.byType(FlatButton), findsNothing); expect(find.byType(TextButton), findsNothing);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets( testWidgets(
...@@ -6297,7 +6297,7 @@ void main() { ...@@ -6297,7 +6297,7 @@ void main() {
); );
// Selected text shows 4 toolbar buttons: cut, copy, paste, select all // Selected text shows 4 toolbar buttons: cut, copy, paste, select all
expect(find.byType(FlatButton), findsNWidgets(4)); expect(find.byType(TextButton), findsNWidgets(4));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets( testWidgets(
...@@ -6346,7 +6346,7 @@ void main() { ...@@ -6346,7 +6346,7 @@ void main() {
); );
// Selected text shows 4 toolbar buttons: cut, copy, paste, select all // Selected text shows 4 toolbar buttons: cut, copy, paste, select all
expect(find.byType(FlatButton), findsNWidgets(4)); expect(find.byType(TextButton), findsNWidgets(4));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets( testWidgets(
...@@ -6628,7 +6628,7 @@ void main() { ...@@ -6628,7 +6628,7 @@ void main() {
); );
// Collapsed toolbar shows 4 buttons: cut, copy, paste, select all // Collapsed toolbar shows 4 buttons: cut, copy, paste, select all
expect(find.byType(FlatButton), findsNWidgets(4)); expect(find.byType(TextButton), findsNWidgets(4));
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets( testWidgets(
...@@ -7006,7 +7006,7 @@ void main() { ...@@ -7006,7 +7006,7 @@ void main() {
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
expect(find.byType(FlatButton), findsNothing); expect(find.byType(TextButton), findsNothing);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.fuchsia, TargetPlatform.linux, TargetPlatform.windows }));
testWidgets('force press selects word', (WidgetTester tester) async { testWidgets('force press selects word', (WidgetTester tester) async {
......
...@@ -2442,7 +2442,7 @@ void main() { ...@@ -2442,7 +2442,7 @@ void main() {
); );
// But don't trigger the toolbar. // But don't trigger the toolbar.
expect(find.byType(FlatButton), findsNothing); expect(find.byType(TextButton), findsNothing);
}, },
); );
...@@ -2564,7 +2564,7 @@ void main() { ...@@ -2564,7 +2564,7 @@ void main() {
); );
// Selected text shows 2 toolbar buttons: copy, select all // Selected text shows 2 toolbar buttons: copy, select all
expect(find.byType(FlatButton), findsNWidgets(2)); expect(find.byType(TextButton), findsNWidgets(2));
}, },
); );
...@@ -2613,7 +2613,7 @@ void main() { ...@@ -2613,7 +2613,7 @@ void main() {
); );
// Selected text shows 2 toolbar buttons: copy, select all // Selected text shows 2 toolbar buttons: copy, select all
expect(find.byType(FlatButton), findsNWidgets(2)); expect(find.byType(TextButton), findsNWidgets(2));
}, },
); );
...@@ -2769,7 +2769,7 @@ void main() { ...@@ -2769,7 +2769,7 @@ void main() {
); );
// Collapsed toolbar shows 2 buttons: copy, select all // Collapsed toolbar shows 2 buttons: copy, select all
expect(find.byType(FlatButton), findsNWidgets(2)); expect(find.byType(TextButton), findsNWidgets(2));
}, },
); );
...@@ -3175,7 +3175,7 @@ void main() { ...@@ -3175,7 +3175,7 @@ void main() {
await gesture.up(); await gesture.up();
await tester.pump(); await tester.pump();
expect(find.byType(FlatButton), findsNothing); expect(find.byType(TextButton), findsNothing);
}); });
testWidgets('force press selects word', (WidgetTester tester) async { testWidgets('force press selects word', (WidgetTester tester) async {
......
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