mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
![]() Fixes [Ability to change Sliders padding](https://github.com/flutter/flutter/issues/40098) Add ability to override default padding so the Slider can fit better in a layout. ### 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 StatefulWidget { const MyApp({super.key}); @override State<MyApp> createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { double _sliderValue = 0.5; @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData( sliderTheme: const SliderThemeData( padding: EdgeInsets.symmetric(vertical: 4.0), thumbColor: Colors.red, inactiveTrackColor: Colors.amber, ), ), home: Scaffold( body: Directionality( textDirection: TextDirection.ltr, child: Center( child: Card( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(4.0)), ), color: Theme.of(context).colorScheme.surfaceContainerHighest, margin: const EdgeInsets.symmetric(horizontal: 16.0), child: Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisSize: MainAxisSize.min, children: [ const Placeholder(fallbackHeight: 100.0), Slider( value: _sliderValue, onChanged: (double value) { setState(() { _sliderValue = value; }); }, ), const Placeholder(fallbackHeight: 100.0), ], ), ), ), ), ), ), ); } } ``` </details> ### Before (Cannot adjust default `Slider` padding to fill the horizontal space in a `Column` and reduce the padded height) <img width="717" alt="Screenshot 2024-10-03 at 15 45 18" src="https://github.com/user-attachments/assets/e9d9a4d1-3087-45b4-8607-b94411e2bd23"> ### After Can adjust default `Slider` padding via `SliderTheme`) <img width="717" alt="Screenshot 2024-10-03 at 15 46 25" src="https://github.com/user-attachments/assets/cd455881-6d52-46cb-8ac6-cc33f50a13ff"> |
||
---|---|---|
.. | ||
flutter | ||
flutter_driver | ||
flutter_goldens | ||
flutter_localizations | ||
flutter_test | ||
flutter_tools | ||
flutter_web_plugins | ||
fuchsia_remote_debug_protocol | ||
integration_test | ||
analysis_options.yaml |