flutter/packages
Taha Tesser 40c22749f5
Add ability to customize the default Slider padding (#156143)
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">
2024-10-30 10:16:23 +00:00
..
flutter Add ability to customize the default Slider padding (#156143) 2024-10-30 10:16:23 +00:00
flutter_driver Upgrade leak tracker. (#157369) 2024-10-23 00:42:28 +00:00
flutter_goldens Upgrade leak tracker. (#157369) 2024-10-23 00:42:28 +00:00
flutter_localizations Upgrade leak tracker. (#157369) 2024-10-23 00:42:28 +00:00
flutter_test Upgrade leak tracker. (#157369) 2024-10-23 00:42:28 +00:00
flutter_tools Fix and remove a few no-shuffle tags in flutter_tools. (#157656) 2024-10-29 19:01:54 +00:00
flutter_web_plugins Upgrade leak tracker. (#157369) 2024-10-23 00:42:28 +00:00
fuchsia_remote_debug_protocol Roll pub packages (#156925) 2024-10-18 20:17:18 +00:00
integration_test Reland "Upgrade tests to AGP 8.7/Gradle 8.10.2/Kotlin 1.8.10" (#157617) 2024-10-29 18:01:19 +00:00
analysis_options.yaml Update old wiki links (#149544) 2024-06-17 17:26:08 +00:00