Taha Tesser
e1cd7b11f6
Introduce Switch.padding (#149884)
fixes [Switch has some padding that leads to uncentered UI](https://github.com/flutter/flutter/issues/148498)
### 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(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ColoredBox(
color: Colors.amber,
child: Switch(
padding: EdgeInsets.zero,
value: true,
materialTapTargetSize: MaterialTapTargetSize.padded,
onChanged: (bool value) {},
),
),
const SizedBox(height: 16),
ColoredBox(
color: Colors.amber,
child: Switch(
value: true,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
onChanged: (bool value) {},
),
),
],
),
),
),
);
}
}
```
</details>
### Default Switch size
<img width="476" alt="Screenshot 2024-07-11 at 13 25 05" src="https://github.com/flutter/flutter/assets/48603081/f9f3f6c6-443d-4bd5-81d4-5e314554b032">
### Update Switch size using the new `Switch.padding` to address [Switch has some padding that leads to uncentered UI](https://github.com/flutter/flutter/issues/148498)
<img width="476" alt="Screenshot 2024-07-11 at 13 24 40" src="https://github.com/flutter/flutter/assets/48603081/aea0717b-e852-4b8d-b703-c8c4999d4863">
2024-07-16 20:25:09 +00:00
..
2024-02-28 13:55:50 -08:00
2023-06-09 11:28:18 +00:00
2023-06-09 11:28:18 +00:00
2024-02-28 13:55:50 -08:00
2024-02-28 13:55:50 -08:00
2024-02-28 13:55:50 -08:00
2023-11-22 20:16:37 +00:00
2023-11-01 23:29:49 +00:00
2023-06-09 11:28:18 +00:00
2024-02-01 00:05:22 +00:00
2024-02-28 13:55:50 -08:00
2024-03-01 12:44:29 +00:00
2024-05-10 22:08:59 +00:00
2023-06-09 11:28:18 +00:00
2024-05-15 18:37:07 +00:00
2023-02-24 06:30:33 -08:00
2024-03-28 22:22:20 +00:00
2024-02-28 13:55:50 -08:00
2024-02-28 13:55:50 -08:00
2024-01-30 16:28:31 -08:00
2024-06-25 21:42:59 +00:00
2023-06-12 14:52:06 +00:00
2024-02-28 13:55:50 -08:00
2023-07-19 22:07:59 +02:00
2023-11-01 23:29:49 +00:00
2024-02-28 13:55:50 -08:00
2023-06-09 11:28:18 +00:00
2024-06-20 19:18:21 +00:00
2024-03-28 22:22:20 +00:00
2022-09-20 14:09:20 -07:00
2024-02-28 13:55:50 -08:00
2023-06-09 11:28:18 +00:00
2024-04-24 11:56:32 +00:00
2023-06-09 11:28:18 +00:00
2023-03-14 17:01:13 +00:00
2023-06-09 11:28:18 +00:00
2024-07-16 20:25:09 +00:00
2024-03-28 17:56:09 +00:00
2024-06-05 20:51:06 +00:00
2023-03-17 10:09:49 -07:00
2024-02-21 10:39:35 +00:00
2024-01-23 09:35:22 +00:00
2024-03-04 20:20:19 +00:00