mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
![]() 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"> |
||
---|---|---|
.. | ||
bin | ||
gen_defaults | ||
gen_keycodes | ||
localization | ||
test | ||
vitool | ||
.gitignore | ||
create_api_docs.dart | ||
dartdoc_checker.dart | ||
examples_smoke_test.dart | ||
find_engine_commit.dart | ||
mega_gallery.dart | ||
pubspec.yaml | ||
repackage_gradle_wrapper.sh | ||
update_icons.dart |