diff --git a/dev/manual_tests/lib/actions.dart b/dev/manual_tests/lib/actions.dart index 000198319a..f8301786a7 100644 --- a/dev/manual_tests/lib/actions.dart +++ b/dev/manual_tests/lib/actions.dart @@ -328,10 +328,18 @@ class _DemoButtonState extends State { @override Widget build(BuildContext context) { - return FlatButton( + return TextButton( focusNode: _focusNode, - focusColor: Colors.red, - hoverColor: Colors.blue, + style: ButtonStyle( + foregroundColor: MaterialStateProperty.all(Colors.black), + overlayColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.focused)) + return Colors.red; + if (states.contains(MaterialState.hovered)) + return Colors.blue; + return null; + }), + ), onPressed: () => _handleOnPressed(), child: Text(widget.name, key: _nameKey), ); @@ -447,7 +455,7 @@ class _FocusDemoState extends State { children: [ Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( + child: ElevatedButton( child: const Text('UNDO'), onPressed: canUndo ? () { @@ -458,7 +466,7 @@ class _FocusDemoState extends State { ), Padding( padding: const EdgeInsets.all(8.0), - child: RaisedButton( + child: ElevatedButton( child: const Text('REDO'), onPressed: canRedo ? () { diff --git a/dev/manual_tests/lib/density.dart b/dev/manual_tests/lib/density.dart index b18a195a4e..5f9c52cc5d 100644 --- a/dev/manual_tests/lib/density.dart +++ b/dev/manual_tests/lib/density.dart @@ -535,25 +535,27 @@ class _MyHomePageState extends State { ), ), _ControlTile( - label: _model.rtl ? 'زر مسطح' : 'Flat Button', - child: FlatButton( - color: m2Swatch[200], + label: _model.rtl ? 'زر مسطح' : 'Text Button', + child: TextButton( + style: TextButton.styleFrom( + primary: Colors.white, + backgroundColor: m2Swatch[200] + ), onPressed: _model.enable ? () {} : null, child: label, ), ), _ControlTile( - label: _model.rtl ? 'أثارت زر' : 'Raised Button', - child: RaisedButton( - color: m2Swatch[200], + label: _model.rtl ? 'أثارت زر' : 'Elevated Button', + child: ElevatedButton( + style: TextButton.styleFrom(backgroundColor: m2Swatch[200]), onPressed: _model.enable ? () {} : null, child: label, ), ), _ControlTile( - label: _model.rtl ? 'زر المخطط التفصيلي' : 'Outline Button', - child: OutlineButton( - color: m2Swatch[500], + label: _model.rtl ? 'زر المخطط التفصيلي' : 'Outlined Button', + child: OutlinedButton( onPressed: _model.enable ? () {} : null, child: label, ), diff --git a/dev/manual_tests/lib/focus.dart b/dev/manual_tests/lib/focus.dart index 04712c2f6c..7f6a7828ed 100644 --- a/dev/manual_tests/lib/focus.dart +++ b/dev/manual_tests/lib/focus.dart @@ -57,11 +57,18 @@ class _DemoButtonState extends State { @override Widget build(BuildContext context) { - return FlatButton( + return TextButton( focusNode: focusNode, autofocus: widget.autofocus, - focusColor: Colors.red, - hoverColor: Colors.blue, + style: ButtonStyle( + overlayColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.focused)) + return Colors.red.withOpacity(0.25); + if (states.contains(MaterialState.hovered)) + return Colors.blue.withOpacity(0.25); + return null; + }), + ), onPressed: () => _handleOnPressed(), child: Text(widget.name), ); @@ -178,7 +185,7 @@ class _FocusDemoState extends State { DemoButton(name: 'Six'), ], ), - OutlineButton(onPressed: () => print('pressed'), child: const Text('PRESS ME')), + OutlinedButton(onPressed: () => print('pressed'), child: const Text('PRESS ME')), const Padding( padding: EdgeInsets.all(8.0), child: TextField( diff --git a/dev/manual_tests/lib/hover.dart b/dev/manual_tests/lib/hover.dart index ee80315ca4..bfd46f4698 100644 --- a/dev/manual_tests/lib/hover.dart +++ b/dev/manual_tests/lib/hover.dart @@ -4,7 +4,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; void main() { runApp(const MaterialApp( @@ -24,7 +23,7 @@ class DemoButton extends StatelessWidget { @override Widget build(BuildContext context) { - return FlatButton( + return TextButton( onPressed: () => _handleOnPressed(), child: Text(name), ); @@ -42,6 +41,11 @@ class _HoverDemoState extends State { @override Widget build(BuildContext context) { final TextTheme textTheme = Theme.of(context).textTheme; + final ButtonStyle overrideFocusColor = ButtonStyle( + overlayColor: MaterialStateProperty.resolveWith((Set states) { + return states.contains(MaterialState.focused) ? Colors.deepOrangeAccent : null; + }) + ); return DefaultTextStyle( style: textTheme.headline4, @@ -60,15 +64,15 @@ class _HoverDemoState extends State { children: [ Row( children: [ - RaisedButton( + ElevatedButton( onPressed: () => print('Button pressed.'), child: const Text('Button'), - focusColor: Colors.deepOrangeAccent, + style: overrideFocusColor, ), - FlatButton( + TextButton( onPressed: () => print('Button pressed.'), child: const Text('Button'), - focusColor: Colors.deepOrangeAccent, + style: overrideFocusColor, ), IconButton( onPressed: () => print('Button pressed'), diff --git a/dev/manual_tests/lib/text.dart b/dev/manual_tests/lib/text.dart index 9835316600..acea6ba382 100644 --- a/dev/manual_tests/lib/text.dart +++ b/dev/manual_tests/lib/text.dart @@ -43,41 +43,53 @@ class _HomeState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - FlatButton( - child: const Text('Test Underlines'), - color: Colors.red.shade800, - textColor: Colors.white, + TextButton( + style: TextButton.styleFrom( + primary: Colors.white, + backgroundColor: Colors.red.shade800, + ), onPressed: () { Navigator.pushNamed(context, 'underlines'); }, + child: const Text('Test Underlines'), ), - FlatButton( - child: const Text('Test Font Fallback'), - color: Colors.orange.shade700, - textColor: Colors.white, + TextButton( + style: TextButton.styleFrom( + primary: Colors.white, + backgroundColor: Colors.orange.shade700, + ), onPressed: () { Navigator.pushNamed(context, 'fallback'); }, + child: const Text('Test Font Fallback'), ), - FlatButton( - child: const Text('Test Bidi Formatting'), - color: Colors.yellow.shade700, - textColor: Colors.black, + TextButton( + style: TextButton.styleFrom( + primary: Colors.black, + backgroundColor: Colors.yellow.shade700, + ), onPressed: () { Navigator.pushNamed(context, 'bidi'); }, + child: const Text('Test Bidi Formatting'), ), - FlatButton( - child: const Text('TextSpan Fuzzer'), - color: Colors.green.shade400, - textColor: Colors.black, + TextButton( + style: TextButton.styleFrom( + primary: Colors.black, + backgroundColor: Colors.green.shade400, + ), onPressed: () { Navigator.pushNamed(context, 'fuzzer'); }, + child: const Text('TextSpan Fuzzer'), ), - FlatButton( - child: const Text('Diacritics Fuzzer'), - color: Colors.blue.shade400, - textColor: Colors.white, + TextButton( + style: TextButton.styleFrom( + primary: Colors.white, + backgroundColor: Colors.blue.shade400, + ), onPressed: () { Navigator.pushNamed(context, 'zalgo'); }, + child: const Text('Diacritics Fuzzer'), ), - FlatButton( - child: const Text('Painting Fuzzer'), - color: Colors.purple.shade200, - textColor: Colors.black, + TextButton( + style: TextButton.styleFrom( + primary: Colors.black, + backgroundColor: Colors.purple.shade200, + ), onPressed: () { Navigator.pushNamed(context, 'painting'); }, + child: const Text('Painting Fuzzer'), ), ], ), @@ -560,6 +572,7 @@ class _UnderlinesState extends State { return Container( color: Colors.black, child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Expanded( child: SingleChildScrollView( @@ -578,37 +591,48 @@ class _UnderlinesState extends State { ), ), Material( - child: ButtonBar( - children: [ - FlatButton( - onPressed: () { - setState(() { - _text += 'i'; - }); - }, - color: Colors.yellow, - child: const Text('ADD i'), - ), - FlatButton( - onPressed: () { - setState(() { - _text += 'w'; - }); - }, - color: Colors.yellow, - child: const Text('ADD w'), - ), - FlatButton( - onPressed: _text == '' ? null : () { - setState(() { - _text = _text.substring(0, _text.length - 1); - }); - }, - color: Colors.red, - textColor: Colors.white, - child: const Text('REMOVE'), - ), - ], + child: Container( + alignment: AlignmentDirectional.centerEnd, + padding: const EdgeInsets.all(8), + child: OverflowBar( + spacing: 8, + children: [ + TextButton( + onPressed: () { + setState(() { + _text += 'i'; + }); + }, + style: TextButton.styleFrom( + backgroundColor: Colors.yellow, + ), + child: const Text('ADD i'), + ), + TextButton( + onPressed: () { + setState(() { + _text += 'w'; + }); + }, + style: TextButton.styleFrom( + backgroundColor: Colors.yellow, + ), + child: const Text('ADD w'), + ), + TextButton( + style: TextButton.styleFrom( + primary: Colors.white, + backgroundColor: Colors.red, + ), + onPressed: _text == '' ? null : () { + setState(() { + _text = _text.substring(0, _text.length - 1); + }); + }, + child: const Text('REMOVE'), + ), + ], + ), ), ), ], @@ -1013,6 +1037,7 @@ class _PaintingState extends State with SingleTickerProviderStateMixin ), Material( child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ SwitchListTile( title: const Text('Enable Fuzzer'), @@ -1042,20 +1067,26 @@ class _PaintingState extends State with SingleTickerProviderStateMixin const ListTile( title: Text('There should be no red visible.'), ), - ButtonBar( - children: [ - FlatButton( - onPressed: _ticker.isActive ? null : () => _update(null), - child: const Text('ITERATE'), - ), - FlatButton( - onPressed: _ticker.isActive ? null : () { - print('The currently visible text is: $_text'); - print(_text.runes.map((int value) => 'U+${value.toRadixString(16).padLeft(4, '0').toUpperCase()}').join(' ')); - }, - child: const Text('DUMP TEXT TO LOGS'), - ), - ], + + Container( + alignment: AlignmentDirectional.centerEnd, + padding: const EdgeInsets.all(8), + child: OverflowBar( + spacing: 8, + children: [ + TextButton( + onPressed: _ticker.isActive ? null : () => _update(null), + child: const Text('ITERATE'), + ), + TextButton( + onPressed: _ticker.isActive ? null : () { + print('The currently visible text is: $_text'); + print(_text.runes.map((int value) => 'U+${value.toRadixString(16).padLeft(4, '0').toUpperCase()}').join(' ')); + }, + child: const Text('DUMP TEXT TO LOGS'), + ), + ], + ), ), ], ),