Commit 7abb083
authored
Add ability to override
Fixes [Long NavigationBar tab titles can't be padded from the sides of the screen](flutter/flutter#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">NavigationDestination.label padding for NavigationBar (#158260)1 parent 2afadc2 commit 7abb083
File tree
5 files changed
+207
-52
lines changed- dev/tools/gen_defaults/lib
- packages/flutter
- lib/src/material
- test/material
5 files changed
+207
-52
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | | - | |
| 33 | + | |
| 34 | + | |
32 | 35 | | |
33 | | - | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | | - | |
47 | | - | |
| 50 | + | |
| 51 | + | |
48 | 52 | | |
49 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| |||
58 | 66 | | |
59 | 67 | | |
60 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| |||
223 | 224 | | |
224 | 225 | | |
225 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
226 | 234 | | |
227 | 235 | | |
228 | 236 | | |
| |||
267 | 275 | | |
268 | 276 | | |
269 | 277 | | |
| 278 | + | |
270 | 279 | | |
271 | 280 | | |
272 | 281 | | |
| |||
423 | 432 | | |
424 | 433 | | |
425 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
426 | 438 | | |
427 | 439 | | |
428 | 440 | | |
| |||
431 | 443 | | |
432 | 444 | | |
433 | 445 | | |
434 | | - | |
| 446 | + | |
435 | 447 | | |
436 | 448 | | |
437 | 449 | | |
| |||
592 | 604 | | |
593 | 605 | | |
594 | 606 | | |
| 607 | + | |
595 | 608 | | |
596 | 609 | | |
597 | 610 | | |
| |||
669 | 682 | | |
670 | 683 | | |
671 | 684 | | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
672 | 690 | | |
673 | 691 | | |
674 | 692 | | |
| |||
1313 | 1331 | | |
1314 | 1332 | | |
1315 | 1333 | | |
1316 | | - | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
1324 | 1342 | | |
1325 | 1343 | | |
1326 | 1344 | | |
1327 | 1345 | | |
1328 | 1346 | | |
1329 | 1347 | | |
1330 | | - | |
| 1348 | + | |
| 1349 | + | |
1331 | 1350 | | |
1332 | | - | |
| 1351 | + | |
| 1352 | + | |
1333 | 1353 | | |
1334 | 1354 | | |
1335 | 1355 | | |
1336 | 1356 | | |
1337 | 1357 | | |
1338 | 1358 | | |
1339 | | - | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
1340 | 1364 | | |
1341 | | - | |
| 1365 | + | |
| 1366 | + | |
1342 | 1367 | | |
1343 | 1368 | | |
1344 | 1369 | | |
| |||
1350 | 1375 | | |
1351 | 1376 | | |
1352 | 1377 | | |
1353 | | - | |
1354 | | - | |
1355 | | - | |
1356 | | - | |
1357 | | - | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
1358 | 1383 | | |
1359 | 1384 | | |
1360 | 1385 | | |
1361 | 1386 | | |
1362 | 1387 | | |
1363 | | - | |
| 1388 | + | |
| 1389 | + | |
1364 | 1390 | | |
1365 | | - | |
| 1391 | + | |
| 1392 | + | |
1366 | 1393 | | |
1367 | | - | |
| 1394 | + | |
| 1395 | + | |
1368 | 1396 | | |
1369 | | - | |
| 1397 | + | |
| 1398 | + | |
1370 | 1399 | | |
1371 | 1400 | | |
1372 | 1401 | | |
| |||
1379 | 1408 | | |
1380 | 1409 | | |
1381 | 1410 | | |
1382 | | - | |
1383 | | - | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
1384 | 1416 | | |
1385 | | - | |
| 1417 | + | |
| 1418 | + | |
1386 | 1419 | | |
1387 | 1420 | | |
1388 | 1421 | | |
| |||
1394 | 1427 | | |
1395 | 1428 | | |
1396 | 1429 | | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
1397 | 1433 | | |
1398 | 1434 | | |
1399 | 1435 | | |
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| |||
109 | 113 | | |
110 | 114 | | |
111 | 115 | | |
| 116 | + | |
112 | 117 | | |
113 | 118 | | |
114 | 119 | | |
| |||
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
| 130 | + | |
125 | 131 | | |
126 | 132 | | |
127 | 133 | | |
| |||
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| 155 | + | |
149 | 156 | | |
150 | 157 | | |
151 | 158 | | |
| |||
162 | 169 | | |
163 | 170 | | |
164 | 171 | | |
| 172 | + | |
165 | 173 | | |
166 | 174 | | |
167 | 175 | | |
| |||
183 | 191 | | |
184 | 192 | | |
185 | 193 | | |
186 | | - | |
| 194 | + | |
| 195 | + | |
187 | 196 | | |
188 | 197 | | |
189 | 198 | | |
| |||
200 | 209 | | |
201 | 210 | | |
202 | 211 | | |
| 212 | + | |
203 | 213 | | |
204 | 214 | | |
205 | 215 | | |
| |||
0 commit comments