Taha Tesser
|
e85340e1e4
|
Deprecate ButtonBar, ButtonBarThemeData, and ThemeData.buttonBarTheme (#145523)
fixes [Deprecate `ButtonBar`](https://github.com/flutter/flutter/issues/127955)
### Code sample
<details>
<summary>expand to view the code sample</summary>
```dart
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
buttonBarTheme: const ButtonBarThemeData(
alignment: MainAxisAlignment.spaceEvenly,
),
),
home: Scaffold(
body: ButtonBar(
alignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
TextButton(
onPressed: () {},
child: const Text('Button 1'),
),
TextButton(
onPressed: () {},
child: const Text('Button 2'),
),
TextButton(
onPressed: () {},
child: const Text('Button 3'),
),
],
),
),
);
}
}
```
</details>
## Data driven fix
### Before executing `dart fix --apply`
```dart
return MaterialApp(
theme: ThemeData(
buttonBarTheme: const ButtonBarThemeData(
alignment: MainAxisAlignment.spaceEvenly,
),
),
home: Scaffold(
body: ButtonBar(
alignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
TextButton(
onPressed: () {},
child: const Text('Button 1'),
),
TextButton(
onPressed: () {},
child: const Text('Button 2'),
),
TextButton(
onPressed: () {},
child: const Text('Button 3'),
),
],
),
),
);
```
### After executing `dart fix --apply`
```dart
return MaterialApp(
theme: ThemeData(
),
home: Scaffold(
body: OverflowBar(
alignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
TextButton(
onPressed: () {},
child: const Text('Button 1'),
),
TextButton(
onPressed: () {},
child: const Text('Button 2'),
),
TextButton(
onPressed: () {},
child: const Text('Button 3'),
),
],
),
),
);
```
|
2024-04-01 11:39:48 +00:00 |
|