Taha Tesser
7abb083ae2
Add ability to override NavigationDestination.label padding for NavigationBar (#158260)
Fixes [Long NavigationBar tab titles can't be padded from the sides of the screen](https://github.com/flutter/flutter/issues/158130)
### 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,
theme: ThemeData(
navigationBarTheme: const NavigationBarThemeData(
labelTextStyle:
WidgetStatePropertyAll(TextStyle(overflow: TextOverflow.ellipsis)),
labelPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 4),
)),
home: Scaffold(
body: Center(
child: Text(
'Custom NavigationBar label padding',
style: Theme.of(context).textTheme.titleMedium,
),
),
bottomNavigationBar: NavigationBar(
destinations: const [
NavigationDestination(
icon: Icon(Icons.favorite_rounded),
label: 'Long Label Text',
),
NavigationDestination(
// icon: SizedBox.shrink(),
icon: Icon(Icons.favorite_rounded),
label: 'Long Label Text',
),
NavigationDestination(
icon: Icon(Icons.favorite_rounded),
label: 'Long Label Text',
),
],
),
),
);
}
}
```
</details>
### Default `NavigationDestination.label` padding with long label
<img width="458" alt="Screenshot 2024-11-06 at 14 30 52" src="https://github.com/user-attachments/assets/637e5e66-e05f-49fa-a4ae-72083b6ff884">
### Custom `NavigationDestination.label` padding with long label
<img width="458" alt="Screenshot 2024-11-06 at 14 32 02" src="https://github.com/user-attachments/assets/23ebf715-30d3-433c-92cd-c8f0fdb1571b">
2024-11-08 14:19:18 +00:00
..
2024-07-16 17:47:18 +00:00
2024-10-22 17:32:05 +00:00
2024-09-06 21:10:35 +00:00
2024-09-04 00:20:16 +00:00
2024-07-22 20:50:50 +00:00
2024-07-23 19:23:07 +00:00
2024-10-17 13:03:22 +00:00
2024-10-17 13:03:22 +00:00
2024-10-31 21:04:57 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-23 19:23:07 +00:00
2024-07-22 20:50:50 +00:00
2024-09-04 18:35:23 +00:00
2024-07-22 20:50:50 +00:00
2024-07-23 19:23:07 +00:00
2024-11-04 22:35:13 +00:00
2024-07-22 20:50:50 +00:00
2024-08-08 16:09:18 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-10-15 12:30:28 +00:00
2024-09-06 19:22:33 +00:00
2024-10-17 19:25:14 +00:00
2024-11-04 22:35:13 +00:00
2024-08-22 03:30:22 +00:00
2024-10-04 18:59:05 +00:00
2024-10-04 18:59:05 +00:00
2024-10-21 19:25:52 +00:00
2024-11-04 22:35:13 +00:00
2024-07-22 20:50:50 +00:00
2024-11-04 22:35:13 +00:00
2024-07-30 16:44:08 +00:00
2024-09-04 00:20:16 +00:00
2024-09-04 00:20:16 +00:00
2024-07-22 20:50:50 +00:00
2024-09-04 16:27:48 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-23 19:23:07 +00:00
2024-10-31 21:07:08 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-10-02 23:48:13 +00:00
2024-10-24 20:12:21 +00:00
2024-07-22 20:50:50 +00:00
2024-07-23 19:23:07 +00:00
2024-07-22 20:50:50 +00:00
2024-08-02 21:16:24 +00:00
2024-10-17 19:25:14 +00:00
2024-07-22 20:50:50 +00:00
2024-11-05 10:54:33 -08:00
2024-10-03 18:21:04 +00:00
2024-07-22 20:50:50 +00:00
2024-09-18 00:19:40 +00:00
2024-07-23 19:23:07 +00:00
2024-07-23 19:23:07 +00:00
2024-10-31 16:09:18 +00:00
2024-07-22 20:50:50 +00:00
2024-07-30 20:38:06 +00:00
2024-07-22 20:50:50 +00:00
2024-09-18 00:19:40 +00:00
2024-09-04 00:20:16 +00:00
2024-09-11 23:59:53 +00:00
2024-07-23 19:23:07 +00:00
2024-07-22 20:50:50 +00:00
2024-10-17 19:25:14 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-10-15 12:30:28 +00:00
2024-07-23 19:23:07 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-31 23:35:24 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-11-04 22:35:13 +00:00
2024-07-22 20:50:50 +00:00
2024-09-04 00:20:16 +00:00
2024-07-22 20:50:50 +00:00
2024-11-05 23:38:51 +00:00
2024-07-22 20:50:50 +00:00
2024-11-04 22:35:13 +00:00
2024-04-08 22:01:05 +00:00
2024-07-22 20:50:50 +00:00
2024-08-07 18:32:37 +00:00
2024-07-22 20:50:50 +00:00
2024-10-22 23:45:41 +00:00
2024-07-22 20:50:50 +00:00
2024-11-06 07:14:05 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-11-08 14:19:18 +00:00
2024-11-08 14:19:18 +00:00
2024-07-22 20:50:50 +00:00
2024-09-11 23:59:53 +00:00
2024-07-22 20:50:50 +00:00
2024-09-11 23:59:53 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-09-18 00:19:40 +00:00
2024-10-02 20:08:11 +00:00
2024-10-02 20:08:11 +00:00
2024-10-17 19:43:20 +00:00
2024-07-22 20:50:50 +00:00
2024-11-04 22:35:13 +00:00
2024-07-22 20:50:50 +00:00
2024-10-30 18:14:11 +00:00
2024-10-30 18:14:11 +00:00
2024-11-04 22:35:13 +00:00
2024-07-22 20:50:50 +00:00
2024-11-04 22:35:13 +00:00
2024-10-17 19:25:14 +00:00
2024-09-11 23:59:53 +00:00
2024-09-08 03:57:20 +00:00
2024-10-27 04:54:30 +00:00
2024-07-22 20:50:50 +00:00
2024-07-08 21:12:04 +00:00
2024-10-15 20:24:48 +00:00
2024-07-22 20:50:50 +00:00
2024-10-15 20:24:48 +00:00
2024-10-03 18:14:51 +00:00
2024-07-22 20:50:50 +00:00
2024-09-18 00:19:40 +00:00
2024-09-30 22:44:20 +00:00
2024-08-06 23:05:03 +00:00
2024-07-22 20:50:50 +00:00
2024-10-30 10:16:23 +00:00
2024-11-04 22:35:13 +00:00
2024-08-29 13:04:18 +00:00
2024-10-18 19:09:13 +00:00
2024-07-22 20:50:50 +00:00
2024-09-11 23:59:53 +00:00
2024-11-04 22:35:13 +00:00
2024-07-22 20:50:50 +00:00
2024-11-04 22:35:13 +00:00
2024-10-08 19:52:38 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-11-04 22:35:13 +00:00
2024-07-22 20:50:50 +00:00
2024-09-18 00:19:40 +00:00
2024-11-04 22:35:13 +00:00
2024-10-21 16:59:16 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-30 01:29:31 +00:00
2024-09-04 16:27:48 +00:00
2024-10-24 20:12:21 +00:00
2024-09-04 16:27:48 +00:00
2024-07-22 20:50:50 +00:00
2024-10-29 10:25:20 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-08-02 23:31:07 +00:00
2024-07-22 20:50:50 +00:00
2024-07-22 20:50:50 +00:00
2024-07-23 19:23:07 +00:00
2024-07-23 19:23:07 +00:00
2024-07-22 20:50:50 +00:00